css3选择器

1、:first-of-type选择所设置元素的第一个原色

//选择第一个p标签
p:first-of-type{
}

2、:last-of-type选择所设置元素的最后一个

//选择最后一个p元素
p:last-of-type{
}

3、:nth-of-type设置所选元素的第几个元素

//选择第二个p标签
p:nth-of-type(2){
}

4、nth-last-of-type()设置倒数第几个元素的样式

//选择元素倒数第二个
p:nth-last-of-type(2){
}

5、:first-child选择第一个子元素

6、:last-child选择最后一个子元素

7、:nth-child()从正序开始选择第几个元素

8、:nth-last-child()从倒叙选择第几个元素

9、::selected选择用户鼠标选中内容的选择器

	p::selected{
		background:red;
	}

10、:not选择非用户指定内容的选择器

	body:not(p){
		background:red;//body标签下除了p标签所有的标签背景颜色都是红色
	}

11、:root根节点选择器

	:root{
		background:red;//所有的元素都变成红色
	}

12、:enabled选择状态可用的元素(input、button) :enabled

input[type="text"]:enabled{
}
//所有type=text的input并且该input处于enabled状态都会受到影响

13、:disabled选择状态不可用的元素(input、button)

	:disabled

14、:checked选择状态下的input标签

	:checked

15、属性选择器 [attr=“value”]

input[type="text"]{
	
}
//所有type=text的input元素都会发生变化

16、target选择器选择当前活动的id锚点

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值