Jump to content


Photo
- - - - -
Resolved

Css for content - on per page basis



This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1 ecee

ecee

    Advanced Member

  • Members
  • 42 posts

Posted 11 May 2012 - 01:09 PM

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!

#2 catrina

catrina

    Advocate

  • Members
  • 12345 posts

Posted 11 May 2012 - 01:34 PM

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:

Please Login or Register to see this Hidden Content


For the blog page, this code:

Please Login or Register to see this Hidden Content


For a regular page (like About Us), this code:

Please Login or Register to see this Hidden Content


...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.

#3 ecee

ecee

    Advanced Member

  • Members
  • 42 posts

Posted 11 May 2012 - 02:32 PM

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!

#4 catrina

catrina

    Advocate

  • Members
  • 12345 posts

Posted 11 May 2012 - 02:42 PM

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

Please Login or Register to see this Hidden Content



#5 ecee

ecee

    Advanced Member

  • Members
  • 42 posts

Posted 11 May 2012 - 02:53 PM

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

#6 catrina

catrina

    Advocate

  • Members
  • 12345 posts

Posted 11 May 2012 - 03:29 PM

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:

Please Login or Register to see this Hidden Content

).

#7 munts

munts

    Member

  • Members
  • 16 posts

Posted 06 November 2012 - 03:08 AM

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

#8 Evan Mattson

Evan Mattson

    Super Member

  • Members

  • 234 posts

Posted 06 November 2012 - 03:53 AM

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!

#9 munts

munts

    Member

  • Members
  • 16 posts

Posted 06 November 2012 - 06:23 PM

Evan,

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

Thanks again,
Scott

#10 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts

Posted 09 November 2012 - 03:58 AM

The topic was marked as resolved.