Reputation: 8546
Is it possible to create dynamic css font classes such as in the title where size
in .font-size
become the parameter used as size
:
.font-size {
font-size: size px;
}
and you could add
<p class="font-14">
which would call
.font-14 {
font-size: 14px;
}
Upvotes: 1
Views: 709
Reputation: 103810
If you want to dynamicaly generate the CSS font declarations with the corresponding classes, you should look into CSS Preprocessors like SASS or LESS.
Here is an example with SCSS :
@for $i from 14 through 30 {
.font-#{$i} {
font-size: $i + px;
}
}
This will output :
.font-14 { font-size: 14px; }
.font-15 { font-size: 15px; }
.font-16 { font-size: 16px; }
...
.font-30 { font-size: 30px; }
Upvotes: 3