css – Nth-child组合跳过2然后选择3

前端之家收集整理的这篇文章主要介绍了css – Nth-child组合跳过2然后选择3前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道这个的nth-child()值:

1 2 3 4 5 6 7 8 9 10

搜索了许多参考文献,如:nth Tester,Mastering the :nth-child,但找不到我需要的组合.

我还在CSS3 :nth-child Calculator上检查了我的组合,它显示了这样的组合:

:nth-child(n+3):nth-child(-n+5):nth-child(n+8):nth-child(-n+10):nth-child(n+13)

有人可以帮助我实现这个目标吗?

解决方法

web-tiki回答不错,但是,使用 :not()可以实现更短的时间:
li:not(:nth-child(5n+1)):not(:nth-child(5n+2)){
    background:gold;
    border:1px solid green;
}
<ol>
  <li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
  <li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
  <li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
  <li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ol>
原文链接:https://www.f2er.com/css/215220.html

猜你在找的CSS相关文章