我希望 Select 列表中匹配nth-child(2n)
的所有元素,但第一个匹配的元素除外;例如...
li:nth-child(2n) {
background: red;
}
li:nth-child(2) {
background: none;
}
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
</ul>
这样做的结果是,只有4、6、8和10的背景 colored颜色 是红色.
不过,我想知道是否有更好的方式来表达CSS规则,以及是否可以将其表达为单一规则:
li:nth-child(2n) {
background: red;
}
li:nth-child(2) {
background: none;
}
这两种方式结合在一起,还能保持原样吗?