CSS Alternate Rows - some rows hidden

前端 未结 6 1279
遥遥无期
遥遥无期 2021-02-12 11:45

I\'m trying to style a table so that each row is a different colour (odd/even). I have the following CSS:

#woo tr:nth-child(even) td {
    background-color: #f0f         


        
6条回答
  •  不思量自难忘°
    2021-02-12 12:06

    Since the "missing stripe phenomenon" only occurs if an odd number of rows is hidden, you might get away with adding a single invisible padding row wherever an odd number of rows is hidden.

    Row 1
    Row 2
    Row 3 (hidden)
    Padding (hidden)
    Row 4
    Row 5
    

    If this actually is a good solution highly depends on your current code, e.g. how you create the table and how rows are hidden.

    But if your tables are huge and large chunks of consecutive rows are hidden, this would perform much better than a Javascript/jQuery solution.

提交回复
热议问题