Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] 第91天 CSS的伪类和伪对象有什么不同? #758

Open
haizhilin2013 opened this issue Jul 15, 2019 · 5 comments
Open

[css] 第91天 CSS的伪类和伪对象有什么不同? #758

haizhilin2013 opened this issue Jul 15, 2019 · 5 comments
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第91天 CSS的伪类和伪对象有什么不同?

@haizhilin2013 haizhilin2013 added the css css label Jul 15, 2019
@HuoXiaoYe
Copy link

  • 伪类:我们常用的比如,hover,focus等,我认为伪类是为了弥补选择器的不足。还有伪类选择器,比如first-child,nth-child.
  • 伪元素 : ::before ::after 是为了创建一个dom元素,使用content属性指定要插入的内容。content必须有值(空值也行)。还有 伪元素选择器,比如 first-line first-letter

@xiangshuo1992
Copy link
Contributor

关于伪元素,之前已经有比较多的讨论了。
#39
#63

@NicholasBaiYa
Copy link

伪类是给当前选中节点添加新样式,
伪对象是给当前选中节点添加伪元素。
伪类选择器使用:,伪对象选择器使用::,因为兼容旧版,所以伪对象使用:也能解析。

@nowherebutup
Copy link

  • 伪类:描述元素的状态,以及用于css选择器
  • 伪元素: 为元素增加子元素,DOM上没有,逻辑存在,一般用于清除浮动,设置子元素...

@Konata9
Copy link

Konata9 commented Aug 22, 2019

伪类是控制元素的行为(:hover, :active, :visited, :focus),当在某个行为下这个元素会呈现什么样式。

伪元素则是一个原本不存在 DOM 上的元素(::before, ::after),必须要设置 content 属性才会生效。

关联回答:

  • [Day13]
  • [Day5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

6 participants