Changing a web page's style based on the time of the year
A fun gimmick that I decided to look into is changing a web page's style based on the current date of the year. Making a page look more frosty when its winter would make for a fun interactive feature that I think would appeal to most. The solution to this simple gimmick was to use CSS custom properties / variables , which allows for different values to be stored and used throughout the CSS file. For a basic web page, variables for the background colour, text colour and a filter for the background image were created (since the filter property will affect all children elements, the background image has been put into a separate div under the 'body' tag with a special 'bg' ID). These variables can be referenced using ' var() '. Then for each unique page style I wanted, I created a new class that modifies the CSS custom properties. CSS classes for the default (root) style and page styles. Now all that's left is to implement some JavaScript that will determin...