CSS for a single page

  • Anonymous

    #3519

    Is there a way to create a differnt CSS for one particular page. For example I want certain styles on my home page (static) different from the rest of the site.

    I’ve tried searching the net and what others have doesn’t seem to work with Graphene.I created two different stylesheet and added this piece of code in header.php of my child theme, heh well doesn’t work.. I’m not too great with php at all. Any help would be appreciated thanks in advanced.

    <?php if ( is_page('special-page') ) { ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/style2.css" type="text/css" media="screen" />
    <?php } else { ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php } ?>
    Mod

    Kenneth John Odle

    #24645

    The home page has a class of .home. To change any feature on just that page, prefix any code with that class. E.g.:

    p {color:blue;}
    .home p {color:red;}

    The first line will change the text of all paragraphs to blue, but the second line will change the text of all paragraphs on the home page to red.

    You can also see this:

    https://forum.graphene-theme.com/graphene-support/adjusting-the-colour-of-links-within-just-posts

    Anonymous

    #24646

    WOW you are the bomb! Thank you very much! 🙂

    Mod

    Kenneth John Odle

    #24647

    Just to further blow your mind, each page/post has a unique ID that’s attached to the <body> tag, so you can target others that way.

    In addition to the .home class, there is also:

    .archive for tag and category archives

    .child-page for child pages (I think)

    I had a post in the last few weeks about this, but can’t find it. But poke around in the stylesheet and use Firebug and you’ll find them all.

    Anonymous

    #24648

    Wow that’s awesome much appreciated thank you!

Viewing 5 posts - 1 through 5 (of 5 total)

  • You must be logged in to reply to this topic.