CSS3-序选择器

  1. 同级别的第几个
  • :first-child 选中同级别中的第一个标签
    :last-child 选中同级别中的最后一个标签
    :nth-child(n) 选中同级别中第n个标签
    :nth-last-child(n) 选中同级别中倒数第n个标签
    注意点:不区分类别
    :only-child 选中父元素中唯一的元素
    :nth-child(odd) 选中同级别中所有奇数
    :nth-child(even) 选中同级别中所有偶数
    :nth-child(xn+y):x和y自定义,n从0开始递增
  1. 同类型的第几个
  • :first-of-type 选中同级别中同类型的第一个标签
    :last-of-type 选中同级别中同类型的最后一个标签
    :nth-of-type(n) 选中同级别中同类型的第n个标签
    :nth-last-of-type(n) 选中同级别中同类型倒数第n个标签
    :only-of-type 选中父元素某一类型的标签
    :nth-of-type(odd)选中同级别中同类型所有奇数
    :nth-of-type(even)选中同级别中同类型所有偶数

你可能感兴趣的:(CSS3-序选择器)