Displaying different header image for particular times of year

Discussion in 'CSS' started by BT Buses, Feb 4, 2008.

  1. #1
    Hi

    I have a header image on my site, but have 3 different styles - 1 for xmas, 1 for easter and another one to display at other times of the year!
    What i'm wanting to know without having to either rename the header image file and upload or change the css file for those 3 times of the year, can css do this by itself at all? ie: in december, it will show the xmas header, at easter, it will show the easter header (dependant obviously on dates) and the rest of the year display just the normal header!

    Here is the code in the css:
    #header {
    background-image: url('site-header.jpg');
    width: 800px;
    height: 100px;
    }

    and here is the code in the php/html page:
    <div id="header"></div>

    and by going to enthusiasts guide to Brisbane Transport, you'll see what i mean, and for the header images, they are:
    http://btbuses.info/site-header%20XMAS.jpg
    http://btbuses.info/site-header%20EASTER.jpg
    http://btbuses.info/site-header.jpg

    Your suggestions are most welcomed. Thankyou...
     
    BT Buses, Feb 4, 2008 IP
    garydee77 likes this.
  2. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #2
    CSS has no method for detecting the date, or making decisions based on the date.

    You can either write a JavaScript that detects the date, and changes the image, or handle it with your server scripting language.
     
    KatieK, Feb 4, 2008 IP
  3. ayushsaran

    ayushsaran Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i can show you the code for this, do you want to do this in php or javascript ?
     
    ayushsaran, Feb 9, 2008 IP
  4. BT Buses

    BT Buses Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Either or, doesn't really matter, although php preferred if possible?

    (sorry for the delay, for some reason never received notification of this thread being responded too).
     
    BT Buses, Jul 27, 2008 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Although changing the CSS file isn't so bad, three times a year?

    Changing the single CSS file of course changes all your pages. I have a page, still friggin sitting on hold, where I have a handful of images that the boss could change if he wanted too... all the images are in the same image file as the rest of the site's images, and the name of the current one is sitting in the CSS:
    background: url(image.gif) center center no-repeat;
    and image.gif gets changed to whatever, so long as it's already in the file. This might ultimately be easier than having a pile of scripts sitting on the server.

    Though for some people it's harder to get to the CSS file, in which case, the scripts can fully automate it.
     
    Stomme poes, Jul 28, 2008 IP