使用::nth-child 选择器
tr:nth-child(odd) { background-color: #ccc; } tr:nth-child(even) { background-color: #F9F9F9; }
odd 奇数行
even 偶数行
效果:
![](https://img2018.cnblogs.com/blog/932245/201908/932245-20190805145337574-1356318152.png)
使用::nth-child 选择器
tr:nth-child(odd) { background-color: #ccc; } tr:nth-child(even) { background-color: #F9F9F9; }
odd 奇数行
even 偶数行
效果:
![](https://img2018.cnblogs.com/blog/932245/201908/932245-20190805145337574-1356318152.png)