table表格红绿相间
<table> <tbody> <tr> <td>1</td> </tr> <tr> <td>2</td> </tr> <tr> <td>3</td> </tr> <tr> <td>4</td> </tr> <tr> <td>5</td> </tr> <tr> <td>6</td> </tr> </tbody> </table>
tbody tr:nth-of-type(2n){ background-color: red; } tbody tr:nth-of-type(2n+1){ background-color: green; }
若选择5-10的子元素。
table tr:nth-child(n+5):nth-child(-n+10) {
background-color: red;
}