:nth-child 和 :nth-last-child CSS 伪类的选择器列表参数

- WD

最新版本的 :nth-child():nth-last-child() 接受可选的 of S 子句,该子句将子元素筛选为仅匹配选择器列表 S 的子元素。例如,:nth-child(1 of .foo) 选择具有 foo 类的子元素中的第一个子元素(忽略该子元素之前的任何非 foo 子元素)。类似于 :nth-of-type,但适用于任意选择器,而不仅仅是类型选择器。

Chrome

  1. 4 - 110: 不支持
  2. 111 - 123: 支持
  3. 124: 支持
  4. 125 - 127: 支持

Edge

  1. 12 - 110: 不支持
  2. 111 - 123: 支持
  3. 124: 支持

Safari

  1. 3.1 - 8: 不支持
  2. 9 - 17.3: 支持
  3. 17.4: 支持
  4. 17.5 - TP: 支持

Firefox

  1. 2 - 112: 不支持
  2. 113 - 124: 支持
  3. 125: 支持
  4. 126 - 128: 支持

Opera

  1. 9 - 97: 不支持
  2. 98 - 108: 支持
  3. 109: 支持

IE

  1. 5.5 - 10: 不支持
  2. 11: 不支持

适用于 Android 的 Chrome

  1. 124: 支持

适用于 iOS 的 Safari

  1. 3.2 - 8.4: 不支持
  2. 9 - 17.3: 支持
  3. 17.4: 支持
  4. 17.5: 支持

Samsung Internet

  1. 4 - 21: 不支持
  2. 22 - 23: 支持
  3. 24: 支持

Opera Mini

  1. 全部: 不支持

Opera Mobile

  1. 10 - 12.1: 不支持
  2. 80: 支持

适用于 Android 的 UC 浏览器

  1. 15.5: 不支持

Android 浏览器

  1. 2.1 - 4.4.4: 不支持
  2. 124: 支持

适用于 Android 的 Firefox

  1. 125: 支持

QQ 浏览器

  1. 14.9: 不支持

百度浏览器

  1. 13.52: 不支持

KaiOS 浏览器

  1. 2.5: 不支持
  2. 3: 不支持

有关仅支持 :nth-child() 的支持信息,请参见 CSS3 选择器支持

资源
Chromium 问题 304163:实现 :nth-child(an+b of S) 和 :nth-last-child(an+b of S) 伪类
Mozilla Bug 854148 - 支持 :nth-child(An+B of sel)、:nth-last-child(An+B of sel) 伪类
MS Edge 平台状态:正在考虑中