Alternate table row color using CSS?

后端 未结 9 1772
囚心锁ツ
囚心锁ツ 2020-11-22 09:03

I am using a table with alternate row color with this.

9条回答
  •  太阳男子
    2020-11-22 09:41

    You have the :nth-child() pseudo-class:

    table tr:nth-child(odd) td{
        ...
    }
    table tr:nth-child(even) td{
        ...
    }
    

    In the early days of :nth-child() its browser support was kind of poor. That's why setting class="odd" became such a common technique. In late 2013 I'm glad to say that IE6 and IE7 are finally dead (or sick enough to stop caring) but IE8 is still around — thankfully, it's the only exception.

提交回复
热议问题