Control Your CSS Via PHP - Good Stuff!
Posted by Tim Koschützki, on May 23, 2007 - in PHP & CakePHP » Other
Today I stumbled upon a cool article that explains how one can control one's CSS colors via PHP to form relative shades. How is this done I hear you asking? Just look at the following code:
php
-
include_once("csscolor.php");
-
$base = new CSS_Color('C9E3A6');
-
$highlight = new CSS_Color('746B8E');
-
?>
-
/* Use the base color, two shades darker */
-
background:#< ?= $base->bg['-2'] ?>;
-
-
/* Use the corresponding foreground color */
-
color:#< ?= $base->fg['-2'] ?>;
-
-
/* Use the highlight color as a border */
Note that we generate a CSS color object and then form lighter or darker shades of it using relativities. That could make generating cool design very easy. Just change the base color and with the relativities the entire design should change accordingly and still be eye-candy. Cool stuff isn't it? :)