gpt4 book ai didi

html - :not all of child element use css?

转载 作者:行者123 更新时间:2023-11-28 01:00:39 24 4
gpt4 key购买 nike

我有一些选择器的子元素,我想为除此选择器之外的所有元素设置属性。我使用这段代码:

*:not(#element):not(#element *) {
font-size: 14px;
}
<div id="element">
<p>Something</p>
</div>
<p>font size is 14px</p>

但它不起作用。

如果我使用 *:not(#element) 它有效,但如果我使用 *:not(#element *) 它无效。

最佳答案

你可以简单地反转你的选择器并指定 #element#element * 有一些不同的字体:

* {
font-size: 14px;
}

#element,
#element * {
font-size: 25px;
}
<div id="element">
<p>Something</p>
</div>
<p>font size is 14px</p>

关于html - :not all of child element use css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42340345/

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