gpt4 book ai didi

html - 如何不在特定标签上应用 CSS

转载 作者:技术小花猫 更新时间:2023-10-29 12:14:08 26 4
gpt4 key购买 nike

我不知道在 CSS 中是否可行,但我希望一般 Angular 色不要应用于我的案例 id=special 中的特定元素。在我的例子中,所有的 DIV 都应该是红色的,但我只希望 id=special 没有应用这种颜色。我知道我总是可以用 id=special 覆盖元素,但我很想知道是否有可能从一般 Angular 色中排除一些。

对 CSS 2 和 CSS 3 有什么想法吗?

例子:

<div>this is red</div>
<div>this is red</div>
<div id="special">this one must be blus</div>
div>this is red</div>

// My General Role
div
{
background-color:Red;
}

最佳答案

CSS3 允许使用 :not() 选择器:

div:not([id])
-or-
div:not(#special)
depending on what you want to exclude

You can read all about the selectors in the w3c docs .

关于 CSS2,there's a limited set of selectors ,并且它们不考虑否定。

关于html - 如何不在特定标签上应用 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7585561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com