Make css nth-child() only affect visible

前端 未结 2 1686
庸人自扰
庸人自扰 2021-02-11 13:57

Is there a way to only affect visible elements with this css?

table.grid tr.alt:nth-child(odd)
{
    background:#ebeff4;
}

table.grid tr.alt:nth-child(even)
{
          


        
2条回答
  •  遥遥无期
    2021-02-11 14:48

    Another option would be to apply a class to the visible elements when hiding the others. Apply nth-child to this class (which is only applied to the visible elements.)

    You don't have to use an !important tag to keep your hover-background in this case.

提交回复
热议问题