css variables
-
I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.
-
I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.
This is something that a lot of people want, and it will likely be available in future releases of CSS. Right now, though, this is not possible. What you can probably do, though, is give your objects a class name -- say,
flexiblePadding_x
, then have a bit of Javascript that runs when the page is loaded searches for all elements having "flexiblePadding_" in their class, makes a note of x, removes the class and adds the appropriate style to the element. It will be a bit of work, but it should get you the results you want. -
I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.
-
I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.
For such similar things you may use expressions in css also. Just google "Expressions in CSS" and you will get a lot of result.
Anurag Gandhi.
http://www.gandhisoft.com
Life is a computer program and every one is the programmer of his own life.
My latest article: Group GridView Data