Slavick
Member
Posted 6 years ago #
Hi :)
is there a way to change css by time?
like 18:00 loads a.css 20:00 loads b.css etc..
Like my header has a nice picture, but i have the same picture in dawn, noon, afternoon and night. Wondering if possible to change them into a night version when the internal clock says 23:00 or so.
i hope you guys can point me to somewhere, looked like everywhere :(
I think you'd have to use a js in order to do this. Check the script sites.
There may be a way for the browser to determine time and @import a different stylesheet, but I don't know it offhand.
php has built in time functions, it would not be that hard to check the time on the server and then use a few if/else (oops) statements to do that. I rotated header images in my old wp1.2 theme quite easily using something similar.
Psuedo-code:
<body>
<div id="header">
<?php
if the_time > 1800 then show pic A
else
if the_time > 1200 then show pic B
else
if the time > 0600 then show pic C
?>
so the css would load each header as a different class to be shown in the header div.
The above isn't ideal but hopefully someone who knows what they are doing will be along soon :)
thats it :)
Instead of calling the image via its name, use a variable -- $headerimage, then change the variable depending on the time.
if the_time > 1200 then $headerimage == path/to/image1
else
if the time > 0600 then $headerimage == path/to/image2
like so ...
I'm so glad there are smart folks out there! Would have never occured to me to use php....
Slavick
Member
Posted 6 years ago #
thank you guys alot :D
changed the css in a php file and now things change on a certain hour.