I was working on some Deki Wiki Skins yesterday and came across the use of Variable in CSS. I have been working with CSS for a while now and haven't used variables, and had never seen them before. I feel pretty dumb for not knowing about that, but now I do, and I like them a bunch.
This is what I came across in Deki Wiki's CSS sheet.
.header .siteNav .userAuth a.userPage:hover {
color: var(linkcolor_hover);
}
#siteNavTree a {
color: var(sitenav_color);
}
There were some more, but that was just a couple. Okay I Google' d CSS variables and I found a good article from the guys at disruptive-innovations. Below is the meat of the article with a link to the full article below the information.
Using the value of a variable as the value or one of the values of a property in a CSS declaration should be achieved using the new functional notation var(). This function takes only one argument being the identifier being the name of the variable. The declaration becomes invalid if the variable does not exist.
Examples:
@variables
{
CorporateLogoBGColor: #fe8d12;
}
div.logoContainer
{
background-color: var(CorporateLogoBGColor);
}
More Examples:
@variables
{
myMargin1: 2em;
}
@variables print
{
myMargin1: 10px;
}
.data, div.entry
{
margin-left: 30px;
margin-left: var(myMargin1);
}
In the example just above, the left margin of an element carrying the class 'data' will be 2em for instance for the 'screen' medium type, and 10px for the 'print' medium type in a user agent conformant to CSS Variables. A legacy non-conformant browser would apply a 30px left margin to such elements in all media types.
I highly recommend reading the full article. It is very good.
~MikePixel (Michael Silva)