[css3] nthchild 和 nthoftype区别

都是基于父级下面的元素

nth-child    基于父级下面的第N个元素,如果类型匹配则生效

nth-of-type  基于父级下面的第N个相同类型的元素

odd:奇数

even:偶数

n:变量

example

<a/>
<p/>
<a/>
a:nth-child(2)   不生效
a:nth-of-type(2) 拿到的是第3个a标签元素
原文地址:https://www.cnblogs.com/lv77/p/14074339.html