nth-child with mod (or modulo) operator

后端 未结 5 1702
忘了有多久
忘了有多久 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:15

    I know this topic is very old, but here's the answer:

        .parent :nth-child(4n):nth-last-child(2) ~ *,
        .parent :nth-child(4n):nth-last-child(3) ~ *,
        .parent :nth-child(4n):nth-last-child(4) ~ * {
            color: gold;
        }
    

    This selector targets all children who are after the last child in the last full set of grouped children denoted by your nth-child formula.

提交回复
热议问题