Forum Moderators: not2easy

Message Too Old, No Replies

Date-Sensitive Css

Date Sensitive CSS

         

BenJancewicz

1:15 pm on Apr 11, 2007 (gmt 0)

10+ Year Member



So, I've got this generic list of events on a webpage I built, and they're ordered by date.

Every time an event passes, I go and grey it out. But I was thinking, "This is mundane. Can I get the CSS to do that for me?"

Does anyone know? I did find someone who was able to change their entire website theme based on the hour of the day:

I'm guessing it would be something very similar to this, but without using "getHours". Am I right?

Has anyone else done this?

~Benjamin

[edited by: SuzyUK at 3:37 pm (utc) on April 11, 2007]
[edit reason] Please no URI's per TOS #13 [WebmasterWorld.com] [/edit]

cucumberdesign

1:21 pm on Apr 11, 2007 (gmt 0)

10+ Year Member



Hi there BenJancewicz,

Did you code the schedule page in PHP? And are the taken from a database or are they static?

EDIT: by the way CSS is not dynamic, but you could use PHP to dynamically change the css class of the date tag.

I have a solution that may work!

Regards,
Byron

Dabrowski

2:44 pm on Apr 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you weren't using anything serverside, which by the look of your page you're not, you'd have to use JS.

It would be possible to get JS to parse the date, and set a class name based on it. You'd have to start by putting the date text in a uniquely identifiable tag, set class='date' or something. You don't actually have to have a CSS definition for .date, it's just so we can ID them.

You'd then split the contents of that tag, the first word would always have to be the month, the first 1 or 2 digits of second word would be the day.

You could then work it out and change the classname.