问题描述
我正在处理一个小的CSS样式表.我想将所有文本内容重新设置为Roboto字体.我在下面编写了这段代码:* {font-family:Roboto!important;}
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;}
现在如何选择图标之外的所有内容(我想从选择器中排除图标(i)标记,有些使用useFontAwesome,有些使用其他图标字体)
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?
推荐答案
对您不想应用样式的类进行否定:
Put a negation for the classes that you don't want to apply the style:
例如:
*:not(.fa) {
font-family: Roboto !important;
}
通常,图标位于"i"元素中,您也可以执行以下操作来影响所有图标:
Usually the icons are in "i" elements, you could do the following as well to affect any icons:
*:not(i) {
font-family: Roboto !important;
}
但是不是必须使用"i"元素,并且可能有一些图标不是"i"标签,也可能是普通文本,而不是"i"标签(尽管这种情况很不常见)
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)
此外,还要考虑到使用!important"不是一个好习惯,尤其是对于如此通用的规则.
Also, take into account that using "!important" is not a good practice, especially with a rule so generic.
这篇关于CSS从*选择器中排除标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!