|
Posted by Curtis on 10/13/46 11:36
CSS: Any way to use variables or constants?
I'm still on the uphill part of the CSS learning curve, but
in designing template/theme/skins for a couple of CMSs, I
keep wishing that CSS were a programming language instead of
a markup/style language. Perhaps there are techniques of
which I'm unaware. If so, someone please clue me in.
What I'd like to see goes something like this:
At the top of a CSS file, one would declare a few of "master
colors" (for example) as constants. For example, in my
header, sidebar, and footer I use the same color of blue as
a background color.
So, as in PHP, we might declare a global
$master_color = thevalue;
then at
..header
{
background-color: $master_color;
}
and
..left_sidebar
{
background-color: $master_color;
}
etc.
Moreover, one might call functions to process $master_color
mathematically to obtain color-complementary or harmonious
shades with functions for font colors, etc., like so:
..left_sidebar .title
{
background-color: title($master_color);
}
where title($parm) would be a function that proportionally
subtracts from R, G, and B to get a darker form of
$master_color, which might be used a dozen places on a
stylesheet--headlines, table-borders. Similarly, one might
get lighter and darker alternating colors of table rows,
etc.
The upshot is, one could do a blue-themed template and
change it to (say) a gray or burnt-orange or purple by
simply changing a couple of constants.
This raises two questions:
1. Are there existing CSS techniques whch would allow
something like this, at least in part? (I'm aware of some
ability to use percentages for some aspects of certain
elements.)
2. If not, is it theoretically possible to generate CSS
sheets with PHP, which would allow the declaration and use
of constants and functions?
--
Curtis
Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.
Navigation:
[Reply to this message]
|