I need to create indefinite divs in my html code, and they differ from each other only by one feature (size, for example).
So, what I am doing right now is to use many css classes, each with the size I need for each div, and one class that contains the rest of my div's style, declaring it as <div class="class1 class2"></div>.
I am looking for a way to incorporate a variable in my css or html to avoid the declaration of a lot of classes, making possible to change the size directly in the code, as an example:
CSS
html { ... }
.name {
...
content: ...;
font: ...;
border: ...;
}
.name_($var) {
...
height: ($var);
width: ($var);
}
HTML
<div class="name name_10"></div> //div 1 size is 10px 10px
<div class="name name_20"></div> //div 2 size is 20px 20px
<div class="name name_50"></div> //div 3 size is 50px 50px
<div class="name name_80"></div> //div 4 size is 80px 80px
This way, it would be possible to have as many divs as I want and it wouldn't be necessary to create one class for each. Is there any way to achieve this only by css and html?! If not, what could help me getting this with jq or js?
Thank you in advance, guys!