我有一些选择器的子元素,我想为除此选择器之外的所有元素设置属性。我使用这段代码:
*: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/