nth-child with mod (or modulo) operator

后端 未结 5 1708
忘了有多久
忘了有多久 2020-12-16 13:10

Is it possible to use the nth-child with modulo? I know you can specify a formula, such as

nth-child(4n+2)

But I can\'t seem t

5条回答
  •  没有蜡笔的小新
    2020-12-16 13:36

    I know this topic is very old, but here's the answer that's close enought to modulo operator:

    :not(:nth-child(7n))
    

    This will select elements 1-6, 8-13 and so on...

    :nth-child(an)
    

    The code above will select elements divisible by "a" so adding :not() selector forces CSS to select elements not divisible by "a".

    I hope someone find it useful ;)

提交回复
热议问题