CSS Specific To Homepage Only - Possible?

Discussion in 'CSS' started by phaze3131, May 27, 2009.

  1. #1
    Hey guys I am wondering how I can display certain CSS only on my homepage or if it is possible.

    I have php code generating html code and want a specific class element hidden only on the homepage, is this possible with CSS at all?

    Or maybe with javascript maybe?

    Thanks all!
     
    phaze3131, May 27, 2009 IP
  2. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #2
    That's very possible. CSS rules are applied in sequence as they are read, so if you have rules for the classes in the main page and load that from a <style> ... </style> section that is read after the general stylesheet then it will override the other setting.
     
    qazu, May 27, 2009 IP
  3. phaze3131

    phaze3131 Well-Known Member

    Messages:
    538
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Yea I see what you mean. The only problem I am having is my home page or lets call it root of my site is here:
    http://www.acne-skin.org/


    and I am trying to get a the same style sheet element, call it class XYZ to display differently on this page of my site
    http://www.acne-skin.org/?gccid=139475


    It's wordpress and I guess it's actually the same page... but maybe there is another CSS way or maybe I will look for a is_root() type of function...

    Maybe I'm just trying for something that can't be done...
     
    phaze3131, May 27, 2009 IP
  4. phaze3131

    phaze3131 Well-Known Member

    Messages:
    538
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Thank you for your help it let me know that I could do this, which is what I did and it worked:

    I added this after the header which is where the style sheet was called.

    <?php
    $x=$_SERVER['REQUEST_URI'];
    if ($x=='/'){
    echo "<style>CUSTOM CSS HERE</style>";
    }
    ?>


    thanks again
     
    phaze3131, May 27, 2009 IP
  5. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #5
    Glad to have helped :)
     
    qazu, May 29, 2009 IP