table表格 css样式

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>
View Code
tbody tr:nth-of-type(2n){  
background-color: red;
}

tbody tr:nth-of-type(2n+1){
background-color: green;
}
View Code

若选择5-10的子元素。

table tr:nth-child(n+5):nth-child(-n+10) {
    background-color: red;
}
posted @ 2017-09-26 16:50  miny_simp  阅读(958)  评论(0编辑  收藏  举报