Change a css background

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deadlyhunta
    New Member
    • Dec 2009
    • 3

    Change a css background

    Hello all,

    I have used javascript a little bit (along time ago) so my knowledge is pretty limited (very limited).
    I am trying to figure out a way that I can change a css background when a certain tag is on a page..

    I.e
    The background image is a picture of a bird because a tag on the page says "bird"

    The tag on the next page says "dogs", so there is a picture of some dogs..

    there would probably be about 7-8 different tags and images

    Is this hard to do ?

    Code:
    .bird{
    	background: url(images/bird.png) left top no-repeat;
    }
    .dog{
    	background: url(images/bird.png) left top no-repeat;
    }
    /* Etc.. */

    If any one could help me out it would be fantastic, i'm sure it's pretty simple for javascript ppl..
    Last edited by Dormilich; Dec 15 '09, 06:53 AM. Reason: Please use [code] tags when posting code
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi,
    can you please explain what do you mean by "tag" here. Are you using any div? Instead of using javascript, writing classes in css for those div's are good practice.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      Do I guess right, that you want to switch class names?

      Comment

      • deadlyhunta
        New Member
        • Dec 2009
        • 3

        #4
        Yes, I want to switch class names when a tag is applied to a page.

        Comment

        • deadlyhunta
          New Member
          • Dec 2009
          • 3

          #5
          The tags will be coming from php and i guess will look something like this.

          Code:
          <div class="<?php if ($tag): print $tag; endif; ?>"></div>

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            well, er, that should do the job?

            Comment

            Working...