Archived

This topic is now archived and is closed to further replies.

  • 0

Resolved Css for content - on per page basis

Question

Posted · Report post

Hi, I made a css customization to the content on front page. But then the content area on other pages (like blog and product pages) changed as well. Is it possible to style the content area, only on a specific page? I also wonder this for example the widget-pad. Maybe I don't want some widgets to be styled, but when I style them it's all or none... Thanks!

Share this post


Link to post
Share on other sites

9 answers to this question

Posted · Report post

Hey Munts,

You can target child pages by using another body class. If you inspect your body classes on your child page, you will see there is a class that identifies the parent page id like so: "parent-pageid-14". You can use this class to target all the child pages of that parent page all at once.

As for targeting widgets on individual pages, you'd have to prefix it with the proper body class and then target the specific widget, they have unique IDs.

BTW, I recently wrote a plugin that allows you to add custom styles to any individual page or post! I'm sure you'd find it useful if you do a lot of special styling for different pages. It lets you write your own custom CSS/LESS that is only loaded on that page, so you don't have to worry about messing with body classes. It doesn't however handle groups of pages (like child pages), that would still have to be done using the parent-pageid-X body class. It's linked down in my signature below if you're interested in learning more about it.

Cheers!

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

The topic was marked as resolved.

Share this post


Link to post
Share on other sites

Posted · Report post

Yes, it is possible to change the style of a content area on a specific page. The same goes for a specific widget in a sidebar. For example, if you want to change the content area (the main content column on the left side of the page) on specifically the homepage, you'd use this CSS:

body.home div.mcolumn-pad {background-color: #yourcolor;}
For the blog page, this code:
body.blog div.mcolumn-pad {background-color: #yourcolor;}
For a regular page (like About Us), this code:
body.page-id-874 {background-color: #yourcolor;}

...and so on. For the regular pages, you need to use that specific page's page ID for the body tag selector (as shown above in the About Us example - since the ID for that page is 874). To find it, you can view your source and look at the

class tag at the top of the page.
2 people like this

Share this post


Link to post
Share on other sites

Posted · Report post

Evan,

Thanks a ton. I will look into the parent-pageid-14... as well as your plugin.

Thanks again,

Scott

Share this post


Link to post
Share on other sites

Posted · Report post

Superthanks again Catrina! I haven't tried it yet, but I think that I get it... I will have a lot of fun customizing tonight :) Is it kind of the same for widgets somehow? Superthanks!

Share this post


Link to post
Share on other sites

Posted · Report post

Correction: The last piece of code in my previous post should look like this...

body.page-id-874 div.mcolumn-pad {background-color: #yourcolor;}

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Great, I kind of wondered why that didn't needed to be there on the last one...so this makes it more clear :)

Share this post


Link to post
Share on other sites

Posted · Report post

If div.mcolumn-pad doesn't change the content area, you can use Firebug to inspect your page for the area that you want to adjust (instructions on how to do that are here: http://www.pagelines.com/wiki/Custom_CSS).

Share this post


Link to post
Share on other sites

Posted · Report post

Catrina,

Thanks a ton for providing this info. It is helping me as well, as I have left sidebar for navigation that I want to be a unique color. However, is there a way to set the background color for the top level page and have it inherrit on only the child pages of that particular section (without having to do something like the following)?

body.page-id-102 .one-sidebar-left {background-color:#666666;}

body.page-id-103.one-sidebar-left {background-color:#666666;}

body.page-id-104 .one-sidebar-left {background-color:#666666;}

body.page-id-105 .one-sidebar-left {background-color:#666666;}

body.page-id-106 .one-sidebar-left {background-color:#666666;}

Thanks again,

Scott

Share this post


Link to post
Share on other sites