Select every other element of class using css3

后端 未结 3 635
夕颜
夕颜 2021-01-12 11:08

Given an ul with a structure like this:

  • ...
  • ...
3条回答
  •  不思量自难忘°
    2021-01-12 11:52

    Could your problem be solved by overriding spot and selecting every other li (like others have mentioned)? Also, you could select the ul by class name.

    How is this:

    .ul_class li:nth-child(even) {
        background: #CCC;
    }
    
    .spot {
        background: green;
    }
    

    The only glitch that might end up looking odd is when 2 spot li`s are right next to each other. I think in every other case spot should look fine.

    I also found that this worked fine in chrome:

    li.product:nth-child(even) {
        background: #ccc;
    }
    

提交回复
热议问题