Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apply style to CSS classes with different numbers

I don't know how to apply style to multiple classes with names .field-img-gallery-0, .field-img-gallery-1, .field-img-gallery-2... etc of course i can write it 50 times, but that's just stupid. can i somehow apply style to all this classes?

like image 851
AlexEfremo Avatar asked Oct 17 '25 13:10

AlexEfremo


1 Answers

The most concise way to do this is with a substring selector on the class attribute, although this won't work for some older browsers:

[class^="field-img-gallery-"] { /* CSS formatting code **/ }

The aboce snippet applies the css formatting to all elements that have a class that starts with field-img-gallery-

like image 51
Coin_op Avatar answered Oct 22 '25 05:10

Coin_op



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!