CSS选择器的语法规则(表格)

选择器例子例子描述
.class.intro选择class="intro"的所有节点
#id#firstname选择id="firstname"的所有节点
**选择所有节点
elementp选择所有p节点
element,elementdiv,p选择所有div节点和所有p节点
element elementdiv p选择div节点内部的所有p节点
element>elementdiv>p选择父节点为div节点的所有p节点
element+elementdiv+p选择紧接在div节点之后的所有p节点
[arttribute][target]选择带有target属性的所有节点
[arttribute=value][target=blank]选择target="blank"的所有节点
[arttribute~=value][title~=flower]选择title属性包含单词flower的所有节点
:linka:link选择所有未被访问的链接
:visiteda:visited选择所有已被访问的链接
:activea:active选择活动链接
:hovera:hover选择鼠标指针位于其上的链接
:focusinput:focus选择获得焦点的input节点
:first-letterp:first-letter选择每个p节点的首字母
:first-linep:first-line选择每个p节点的首行
:first-childp:first-child选择属于父节点的第一个子节点的所有p节点
:beforep:before在每个p节点的内容之前插入内容
:afterp:after在每个p节点的内容之后插入内容
:lang(language)p:lang选择带有以it开头的lang属性值的所有p节点
element~element2p~ul选择前面有p节点的所有ul节点
[attribute^=value]a[src^=“https”]选择其src属性值以https开头的所有a节点
[attribute$=value]a[src$=".pdf"]选择其src属性以.pdf结尾的所有a节点
[attribute*=value]a[src*=“abc”]选择其src属性中包含abc子串的所有a节点
:first-of-typep:first-of-type选择属于其父节点的首个p节点的所有p节点
:last-of-typep:last-of-type选择属于其父节点的最后p节点的所有p节点
:only-of-typep:only-of-type选择属于其父节点的唯一的p节点的所有p节点
:only-childp:only-child选择属于其父节点的唯一子节点的所有p节点
:nth-child(n)p:nth-child选择属于其父节点的第二个子节点的所有p节点
:nth-last-child(n)p:nth-last-child同上,从最后一个子节点开始计数
:nth-of-type(n)p:nth-of-type选择属于其父节点第二个p节点的所有p节点
:nth-last-of-type(n)p:nth-last-of-type同上,但是从最后一个子节点开始计数
:last-childp:last-child选择属于其父节点最后一个子节点的所有p节点
:root:root选择文档的根节点
:emptyp:empty选择没有子节点的所有p节点(包括文本节点)
:target#news:target选择当前活动的#news节点
:enabledinput:enables选择每个启用的input节点
:disabledinput:disabled选择每个禁用的input节点
:checkedinput:checked选择每个被选中的input节点
:not(selector):not选择非p节点的所有节点
::selection::seclection选择被用户选取的节点部分
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dunkle.T

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值