Skip to main content

结构伪类 nth-of-type

  • :nth-of-type() 用法跟 :nth-child() 类似
  • 不同点是 :nth-of-type() 计数时只计算同种类型的元素,其它的全部去除。

:nth-of-type() 这个 CSS 伪类是针对具有一组兄弟节点的标签,用 n 来筛选出在一组兄弟节点的位置。

/* 在每组兄弟元素中选择第四个 <p> 元素 */
p:nth-of-type(4n) {
color: lime;
}

Loading Github Gist ...
Details