鉴于下面的 HTML,您将如何选择所有不是 .itemcontainer(s) 后代的 .name(s)。
类似 .group .header .name:not(descended from .itemcontainer)
我知道这可以很容易地用 jQuery 或通过添加其他类来完成,但是任何纯 css 解决方案?我一直无法找到“不是来自”选择器...
<div class='group'>
<!-- Any number of ancestors of any type -->
<div class='header'>
<!-- Any number of ancestors of any type -->
<div class='name'>
SELECT ME!!!
</div>
</div>
<div class='body'>
<div class='itemcontainer'>
<div class='item1'>
<!-- Any number of ancestors of any type -->
<div class='header'>
<!-- Any number of ancestors of any type -->
<div class='name'>
DON'T SELECT ME!!!
</div>
</div>
<div class='body'>
...
</div>
</div>
...
</div>
</div>
...
</div>
谢谢!