domingo, 8 de maio de 2016

CSS - How to change all classes that begin with a certain string?

Hi :)

I needed to change all classes whose names begin with "icon-" for example: .icon-home, .icon-user, .icon-shopping-cart, .icon-th

and instead doing something like this:

.icon-home, .icon-user, .icon-shopping-cart, .icon-th, .icon-minus, .icon-plus, .icon-trash, icon-chevron-down, icon-signout {
    font-family: FontAwesome!important;
}

I did the same thing using this approach:

i, [class^="icon-"], [class*=" icon-"] {
    font-family: FontAwesome!important;
}

it is a little better :) regular expressions rocks :D

I don't know very well how it works, but you can read more here:
http://stackoverflow.com/questions/23963073/css-regex-selector-match-one-or-another-condition
https://css-tricks.com/attribute-selectors/

Best regards,
Adriano Schmidt

Nenhum comentário:

Postar um comentário