Possible Duplicate:
Create a variable in .CSS file for use within that .CSS file
I heard about that we can declare/define variable in CSS and use them like global variables like this:
@nice-blue: #5B83AD; #header { color: @nice-blue; }
So anyone knows how to use them?
The var() function is used to insert the value of a CSS variable. CSS variables have access to the DOM, which means that you can create variables with local or global scope, change the variables with JavaScript, and change the variables based on media queries.
To declare a variable in CSS, come up with a name for the variable, then append two hyphens (–) as the prefix. The element here refers to any valid HTML element that has access to this CSS file. The variable name is bg-color , and two hyphens are appended.
The @property “at-rule” in CSS allows you to declare the type of a custom property, as well its as initial value and whether it inherits or not.
For that you need to use Less or Sass which are CSS Dynamic languages.
here's some comparison between both technologies.
You need to use something like SASS
http://sass-lang.com/#variables
or Less
http://lesscss.org/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With