我正在尝试选择每个第3个section
标记,但从第四个开始。所以下面的粗体元素将表明我想选择的那些:
我已尝试过以下代码,但似乎无法正常工作
section:nth-child(3n+1)
答案 0 :(得分:4)
如果您想从第4个元素开始,请使用+4
而不是+1
section:nth-child(3n+4) {
color: red;
}

<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
<section>Section</section>
&#13;
答案 1 :(得分:3)
答案 2 :(得分:1)
section:nth-child(3n + 4)
或section:nth-child(3n + 1):not(:first-child)
。