首页 > 关于css伪类选择器中:nth-of-type(n) 选择器

关于css伪类选择器中:nth-of-type(n) 选择器

谁能够解释下下面图片中的 :nth-of-type(4n+1) :nth-of-type(n) 这样的选择器??


这种问题查MDN最好

https://developer.mozilla.org/zh-CN/docs/Web/CSS/:nth-of-type


CSS选择器之:nth-child(n)与:nth-last-of-type(number)


这位大哥解释的很好,我就不搬了,自己看CSS3选择器:nth-child和:nth-of-type之间的差异


:nth-of-type(n)只计算父元素中指定的某种类型的子元素
“n”是其参数,而且可以是整数值(1,2,3,4),也可以是表达式(2n+1、-n+5)和关键词(odd、even),但参数n的起始值始终是1,而不是0。也就是说,参数n的值为0时,选择器将选择不到任何匹配的元素。

【热门文章】
【热门文章】