简体   繁体   English

CSS 从 * 选择器中排除标签

[英]CSS exclude a tag from * selector

I'm working on a small CSS style sheet.我正在研究一个小的 CSS 样式表。 I want to restyle all the Text content to a Roboto font.我想将所有文本内容重新设置为 Roboto 字体。 I wrote this code below: *{font-family:Roboto;important;}我在下面写了这段代码:*{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)现在如何 select 除了图标之外的所有内容(我想从我的选择器中排除图标(i)标签,有些确实使用FontAwesome 有些使用其他图标字体)

So is there something that I can add to the * selector to select everything aside fro the icons?那么有什么我可以添加到*选择器到 select 除了图标之外的所有东西吗?

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:通常图标位于“i”元素中,您也可以执行以下操作来影响任何图标:

*: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)但是使用“i”元素不是强制性的,可能有图标不是“i”标签,以及普通文本作为“i”标签(虽然这很不寻常)

Also, take into account that using ",important" is not a good practice.另外,请考虑使用“,重要”不是一个好习惯。 especially with a rule so generic.尤其是对于如此通用的规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM