答案 0 :(得分:3)
这应该有效:
:not(:nth-child(3n))
答案 1 :(得分:2)
您可以使用:nth-child()
和:not()
伪类来执行此操作,该类将选择除每3 div
div:not(:nth-child(3n)) {
color: green;
}

<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
&#13;
另一种方法是选择div:nth-child(3n + 1)
和div:nth-child(3n + 2)
div:nth-child(3n +1),
div:nth-child(3n + 2) {
color: green;
}
&#13;
<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
<div>Div</div>
&#13;
答案 2 :(得分:0)
这很好用
div:nth-child(3n) {
background: black;
}