选择器

本文深入解析CSS选择器的使用方法,包括ID选择器、类选择器、元素选择器等,覆盖了基本选择器、层级选择器、表单选择器等多种类型,帮助读者全面掌握CSS选择器的使用技巧。
      • #id    用于搜索的,通过元素的 id 属性中给定的值
      • element   一个用于搜索的元素。指向 DOM 节点的标签名。
      • .class  一个用以搜索的类。一个元素可以有多个类,只要有一个符合就能被匹配到。
      • *  找到每一个元素
      • selector1,selector2,selectorN  你可以指定任意多个选择器,并将匹配到的元素合并到一个结果内。
  • 层级

    • ancestor descendant
    • parent > child
    • prev + next
    • prev ~ siblings
  • 基本

    • :first
    • :not(selector)
    • :even
    • :odd
    • :eq(index)
    • :gt(index)
    • :lang1.9+
    • :last
    • :lt(index)
    • :header
    • :animated
    • :focus
    • :root1.9+
    • :target1.9+
  • 内容

    • :contains(text)
    • :empty
    • :has(selector)
    • :parent
  • 可见性

    • :hidden
    • :visible
  • 属性

    • [attribute]
    • [attribute=value]
    • [attribute!=value]
    • [attribute^=value]
    • [attribute$=value]
    • [attribute*=value]
    • [attrSel1][attrSel2][attrSelN]
  • 子元素

    • :first-child
    • :first-of-type1.9+
    • :last-child
    • :last-of-type1.9+
    • :nth-child
    • :nth-last-child()1.9+
    • :nth-last-of-type()1.9+
    • :nth-of-type()1.9+
    • :only-child
    • :only-of-type1.9+
  • 表单

    • :input
    • :text
    • :password
    • :radio
    • :checkbox
    • :submit
    • :image
    • :reset
    • :button
    • :file
    • :hidden
  • 表单对象属性

    • :enabled
    • :disabled
    • :checked
    • :selected

转载于:https://www.cnblogs.com/wantnewlive/p/9950945.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值