Rotate background color without using for-each

后端 未结 3 725
遇见更好的自我
遇见更好的自我 2021-01-24 19:38

I am trying to set the background color of every other I am not using a for-each loop since I am using a few templates to filter data based on the nodes

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-24 20:16

    You could do this in CSS by using :nth-child([even/odd]) :

    tr:nth-child(even) td {
        background-color: #fff;
    }
    tr:nth-child(odd) td {
        background-color: #ccc;
    }
    

    However, this will not work on older browsers.

提交回复
热议问题