gpt4 book ai didi

html - CSS :not on the parent does not work for descendant selectors but it does for child selectors, 除非您明确指定父元素类型

转载 作者:行者123 更新时间:2023-11-28 04:31:48 25 4
gpt4 key购买 nike

<分区>

fiddle :http://jsfiddle.net/Lnrn97a7/2/

HTML:

<div id="outer">
<div class="c1">
c1 should be black
</div>
<div class="c2">
c2 should be black
</div>
<div class="c3">
c3 should be black
</div>
</div>
<div id="somethingelse">
<div class="c1">
c1 should be red
</div>
<div class="c2">
c2 should be red
</div>
<div class="c3">
c3 should be red
</div>
</div>

CSS:

:not(#outer) .c1 {
color: #ff0000;
}

div:not(#outer) .c2 {
color: #ff0000;
}

:not(#outer) > .c3 {
color: #ff0000;
}

对于 c1,我有一个不包括父元素类型的后代规则。对于 c2,我有一个包含父元素类型的后代规则。对于 c3,我有一个不包括父元素类型的直接子规则。只有 c2 和 c3 按预期工作。为什么?

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