序选择器

    xiaoxiao2021-03-25  88

    1.同级别的第几个 :first-child 选中同级别中的第一个标签 :last-child 选中同级别中的最后一个标签 :nth-child(n) 选中同级别中的第n个标签 :nth-last-child(n) 选中同级别中的倒数第n个标签 :only-child 选中父元素中唯一的标签 注意点: 不区分类型

    2.同类型的第几个 :first-of-type 选中同级别中同类型的第一个标签 :last-of-type 选中同级别中同类型的最后一个标签 :nth-of-type(n) 选中同级别中同类型的第n个标签 :nth-last-of-type(n) 选中同级别中同类型的倒数第n个标签 :only-of-type 选中父元素中唯一类型的某个标签

    :nth-child(odd) 选中同级别中的所有奇数 :nth-child(even) 选中同级别中的所有偶数

    :nth-child(xn+y) x和y是用户自定义的, 而n是一个计数器, 从0开始递增

    p:first-child{ color: red; }
    转载请注明原文地址: https://ju.6miu.com/read-36326.html

    最新回复(0)