子元素的伪类

Author Avatar
Ninefire 6月 06, 2018
  • 在其它设备中阅读本文章
  • :first-child 选择第一个子元素
  • :last-child 选择最后一个子元素
  • :nth-child 选择指定位置的子元素
    三种写法:
    • :nth-child(n) 选中第n个子元素
    • :nth-child(even) 选中偶数位置的子元素
    • :nth-child(odd) 选中奇数位置的子元素

  • :first-of-type 选择第一个指定类型的子元素
  • :last-of-type 选择最后一个指定类型的子元素
  • :nth-of-type 选择指定类型中指定位置的子元素

注意:child,是在所有子元素中排列;type,是在指定类型的子元素中排列。
PS:元素即标签,标签即元素。

如发现错误请联系我,谢谢你。
本文链接:http://ninefire.tk/HTML&CSS.basics/16.html