问题
I'm working on a small CSS style sheet. I want to restyle all the Text content to a Roboto font. I wrote this code below : *{font-family:Roboto !important;}
Now How to select everything aside from the icon( I want to exclude the icons (i) tag from my selector, some do useFontAwesome some use other icon fonts)
So is there something that I can add to the * selector to select everything aside fro the icons?
回答1:
Put a negation for the classes that you don't want to apply the style:
For example:
*:not(.fa) {
    font-family: Roboto !important;
}
Usually the icons are in "i" elements, you could do the following as well to affect any icons:
*:not(i) {
    font-family: Roboto !important;
}
But using "i" elements is not mandatory, and there could be icons that are not as "i" tags, as well as normal text as "i" tags (although this is very unusual)
Also, take into account that using "!important" is not a good practice, especially with a rule so generic.
来源:https://stackoverflow.com/questions/61001451/css-exclude-a-tag-from-selector