ChatterBank3 mins ago
css which changes with time
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?
Answers
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.
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.
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.
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.