How can I style even and odd elements?

后端 未结 9 2219
离开以前
离开以前 2020-11-22 10:44

Is it possible to use CSS pseudo-classes to select even and odd instances of list items?

I\'d expect the following to produce a list of alternating colors, but inste

9条回答
  •  感动是毒
    2020-11-22 11:13

    The :nth-child(n) selector matches every element that is the nth child, regardless of type, of its parent. Odd and even are keywords that can be used to match child elements whose index is odd or even (the index of the first child is 1).

    this is what you want:

    
        
            
        
        
            
    • ho
    • ho
    • ho
    • ho
    • ho

提交回复
热议问题