02_伪类和伪元素

01_动态伪类

为了便于区分, 一般伪元素用两个冒号.

:link, :visited, :hover, :active 应用于 a 元素

在这里插入图片描述

在这里插入图片描述

:hover, :active 应用于其他元素

在这里插入图片描述

:focus 使用

在这里插入图片描述
在这里插入图片描述

02_目标伪类

:target

在这里插入图片描述

03_语言伪类

:lang()

04_元素状态伪类

:enabled, :disabled, :checked

在这里插入图片描述

05_结构伪类

:nth-child()

在这里插入图片描述

在这里插入图片描述

:nth-last-child()

  • 选中倒数的元素, 其余和nth-child()相同

:nth-of-type()

在这里插入图片描述

:nth-last-of-type()

  • 选中倒数的元素, 其余和nth-of-type()相同

:first-child, :last-child, :first-of-type, :last-of-type

  • :first-child == nth-child(1)
  • :last-child == nth-last-child(1)
  • :first-of-type == nth-of-type(1)
  • :last-of-type == nth-last-of-type(1)

:only-child, :only-of-type

  • :only-child, 父元素中的唯一子元素
  • :only-of-type, 父元素中同类型的唯一子元素

在这里插入图片描述

:root

  • :root == html , 根元素, 即 HTML 元素

:empty

  • 元素内容为空

在这里插入图片描述

06_否定伪类

:not()

  • :not(x) 除 x 之外其他元素都拥有属性
  • x 可以是元素选择器, 通用选择器, 属性选择器, 类选择器, id 选择器, 伪类(除否定伪类)

07_伪元素-first-letter, first-line

在这里插入图片描述

08_伪元素-before-after

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值