从我在网上看到的所有例子来看,似乎我必须要使用 nth-child 不止一个 div。
我可以让它只对一个 div 起作用吗?
.section:nth-child(odd) {
background-color: red;
}
<div class="section">
最佳答案
:nth-child(odd)
适用于任意数量的元素。如果只有一个,它适用于第一个。
请在此处查看您的示例:http://jsfiddle.net/Fz3vP/
关于html - nth-child可以用在一个div上吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23901127/