Nocide Mugen Nocide Mugen - 5 months ago 72
CSS Question

Css for multiple class

I'd like to know if it's possible to use css for multiple class with the same name with one exception an iterator inside :

<div class="elem-1"></div>

<div class="elem-2"></div>

If it's possible, how should I use my css to implement those two classes (can be lot more than 2)?


You could use CSS attribute selectors like this:

[class^="elem-"], [class*=" elem-"] {
  /* style properties */

But I would rather suggest to use 2 classes like this

<div class="elem specialStuffClass">...</div>

Another option might be to use counting selectors like nth-child.