CSS nth-child for greater than and less than

前端 未结 6 1532
萌比男神i
萌比男神i 2021-01-31 13:24

In my HTML I have,

6条回答
  •  爱一瞬间的悲伤
    2021-01-31 14:04

    If it's just 1 and 2 you don't want the style applied to you can do something like this instead:

    .container {
        background: yellow;
    }
    
    .container:first-child,
    .container:first-child + .container {
        background: transparent;
    }
    

    The yellow background will apply to every container except for the first child and the one following it.

提交回复
热议问题