Donate SIGN UP

css which changes with time

Avatar Image
merdok | 18:33 Thu 16th Feb 2006 | Technology
6 Answers

Hi guys,


I've just started to really use CSS in my websites and one of the sites I am making needs to be quite showey... I'd love it if I could make my header image alter depending what time of day it was.


Does anyone have any idea how to do this?

Gravatar

Answers

1 to 6 of 6rss feed

Best Answer

No best answer has yet been selected by merdok. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.

Hello.


I dont think your looking at CSS Here, i think it's going to be more JavaScript or PHP.


I have found a tutorial for you, and it's linked below.


Thanks alot.


Leigh.


EXTERNAL LINKS:


http://www.javascriptkit.com/javatutors/time2.shtml


JavaScript Kit tutorial.



CSS doesn't have any conditional logic in it as far as I know, so you can't use that.

JavaScript is probably the easiest way of doing it.

I'll post something on my site to show you how...
You can use javascript to apply a different stylesheet to your site depending on what time of day etc it is but if you're not making such an exhaustive change then I'd leave the CSS alone.

Just use javascript (or asp or php) to put a different image in.
This page
http://www.w3schools.com/js/tryit.asp?filename=tryjs_els eif
does 99% of the coding for you : you just need to put in :
document.write("<img src='image1.jpg' alt='alt text' height='4' width='55' />")

in place of "document.write" lines already there. Remember that if you would normally have double quotes inside your image tags, use an apostrophe instead as the double quotes start and end the "document.write" command.
*tut*

I'll have to FTP the page I have up for you when I get home. Not got access to my site here... I'll let you know when I've done it.
Here you are :

http://www.bezirc.co.uk/scratch/test.html

This will show 'Morning' before 12pm, and Afternoon any time after.

It's basic, but demonstrates what you want to do.

You can test it by changing the time on your PC.
Question Author
Excellent, thanks for all your help guys!

1 to 6 of 6rss feed

Do you know the answer?

css which changes with time

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.