我目前正在为高中学生的网络发展区域锦标赛做准备.准备工作是锦标赛网站要解决的问题之一。我有以下HTML代码:
<h2>Task 6</h2>
<article id="task-6">
<div class="marble" data-target></div>
<section class="first">
<div class="marble" data-target></div>
<div class="marble"></div>
<div class="marble" data-target></div>
</section>
<div class="marble"></div>
<section class="last">
<div class="marble" data-target></div>
<div class="marble"></div>
<div class="marble" data-target></div>
</section>
<div class="marble" data-target></div>
</article>我的目标是选择带有标记为marble的data-target类的div,但如下所示:
。
- `:nth-child`
- `:nth-last-child`
- `:nth-of-type`
- `:nth-last-of-type`
- `[data-target]`
- nor any use of `+` or `~`我尝试了下面的选择器,但是它只选择了部分元素中的div。
#task-6 section div:not(:not(:first-child):not(:last-child))你能帮帮我吗。非常感谢。
发布于 2022-09-25 10:03:09
您尝试过的选择器-
#task-6 section div:not(:not(:first-child):not(:last-child))它显式地表示要对div内部区段元素进行工作。
只需从其中移除部分,它应该适用于每个元素。
#task-6 div:not(:not(:first-child):not(:last-child))https://stackoverflow.com/questions/73843558
复制相似问题