is there any way to assign variable for css claas name?
I am looking to assign variable names to css class dynamically. Here im explaining with smal开发者_C百科l code
#A1, #A2, #A3, #A4{
float: left;
clear: left;
width: 300px;
margin: 15px;
}
instead of writing " #A1, #A2, #A3, #A4" , i want to write some variable. with for loop i want to define four classes while page is getting loaded.
could you pls explain me how to do that?
Why not use a css class selector?
You can then use the jQuery addClass method to assign to elements.
//apply class to all divs
$('div').addClass('someclass')
.someclass {
float: left;
clear: left;
width: 300px;
margin: 15px;
}
You could always serve a PHP file as CSS.
http://net.tutsplus.com/tutorials/php/supercharge-your-css-with-php-under-the-hood/
Alternatively look at Less (either as rubygem or less.js) or SASS (also ruby)
http://lesscss.org/
http://sass-lang.com/
精彩评论