Random CSS

December 9, 2005

{CSS Colors: Take Control Using PHP }

I’ve been wanting to mess around with CSS and PHP for a while now, with something similar to this. I wish I were a better programmer. I’d seriously like to have a php script randomize the color base of a stylesheet. Like this page, lots of monochrome reds and blacks. What would happen, if you could script this to be a different color, on each refresh? So instead of red/black, it would use a color harmony wheel, to have a complementary design on each visit. It’s probably a one-liner in Flash.

How about if you could do the layout in the same way? Joshua Davis’ art is random, why can’t a blog design? I’m not talking about having 15+ stylesheets in a directory and having those pull up in random order. I’m talking about having a constant….your text then building custom layouts around that. So each visitor would have a different layout. It’s far out, I know, but it’s just an idea I’d like to see.


I’m testing some ideas with this at http://www.mkelley.com/weblog/test.php

Right now, it’s changing the background of the page and of the div’s randomly. Pulling in 0-9 and a-f randomly as the background-color. Apply this to a layout, then layer a transparent PNG or GIF on top, and you could have random colors in a static design. Kinda like a silkscreen process. (Silkscreen CSS from here on out.)

All of this is done through PHP.


Ok, now I have this . It’s not random, not at all. But it’s the basis for doing a random design. I’m creating a png that I can set as a background image…the same method I use to have nice columns on this site. I might make a base file, then have random colors over the top. PHP is nice. I’m now looking at using polygons instead of rectangles to get what i want.