:nth-child与指定区间范围列表高亮实例页面
展示
代码
-
HTML:
<table> <thead> <tr> <th scope="col" width="60">排名</th> <th scope="col">姓名</th> <th scope="col">总积分</th> </tr> </thead> <tr> <td>1</td> <td><a href>XboxYan</a></td> <td>105</td> </tr> <tr> <td>2</td> <td><a href>liyongleihf2006</a></td> <td>78</td> </tr> ... </table>
-
CSS:
tr:nth-child(-n + 3) td { background: cornsilk; } tr:nth-child(n + 4):nth-child(-n + 10) td { background: mintcream; }