Click to See Complete Forum and Search --> : set variables in css?


BassMasterFlash
06-07-2006, 08:01 PM
Just a question. Is there a way to set varibles in css. For instance...

Say you define some colors:

color1 = #333
color2 = #CCC

And then you could call on them when defining selector properties:

.container{
background-color:color1;
border:1px solid color2;
}

See what I'm going for here? That way you could set your primary colors all in one spot, and then the changes would apply to your entire sheet(s).

So later down the road if you decide you want to change color2 to '#999', it would cascade down changing all the styles you have color2 specified.

Ideas?

ray326
06-07-2006, 10:07 PM
.backcolor { background: #333 }
.forecolor { color: #ccc }

Then use those classes in your mark up.

<div class="container backcolor forecolor">