Alternate background colors for list items

前端 未结 9 1844
一向
一向 2020-12-04 07:42

I have a list, and each item is linked, is there a way I can alternate the background colors for each item?

9条回答
  •  一向
    一向 (楼主)
    2020-12-04 08:22

    You can by hardcoding the sequence, like so:

    li, li + li + li, li + li + li + li + li {
      background-color: black;
    }
    
    li + li, li + li + li + li {
      background-color: white;
    }
    

提交回复
热议问题