下面我将用几个典型的实例来给大家讲解:nth-child的实际用途:

Tips:还用低版本的IE浏览器的哥们请绕过!

:nth-child(2)选取第几个标签,“2可以是你想要的数字”CSS中:nth-child的用法

.demo01 li:nth-child(2){background:#090}

 :nth-child(n+4)选取大于等于4标签,“n”表示从整数,下同CSS中:nth-child的用法

.demo01 li:nth-child(n+4){background:#090}

:nth-child(-n+4)选取小于等于4标签CSS中:nth-child的用法

.demo01 li:nth-child(-n+4){background:#090}

:nth-child(2n)选取偶数标签,2n也可以是evenCSS中:nth-child的用法

.demo01 li:nth-child(2n){background:#090}

:nth-child(2n-1)选取奇数标签,2n-1可以是oddCSS中:nth-child的用法

.demo01 li:nth-child(2n-1){background:#090}

:nth-child(3n+1)自定义选取标签,3n+1表示“隔二取一”CSS中:nth-child的用法

.demo01 li:nth-child(3n+1){background:#090}

:last-child选取最后一个标签CSS中:nth-child的用法

.demo01 li:last-child{background:#090}

:nth-last-child(3)选取倒数第几个标签,3表示选取第3个CSS中:nth-child的用法

.demo01 li:nth-last-child(3){background:#090}


原文:https://www.cnblogs.com/guozh/p/10161623.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2021-06-25
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
相关资源
相似解决方案