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 伪类和伪元素( : 与 ::) 区别 #3

Open
oliver1204 opened this issue Dec 9, 2016 · 0 comments
Open

CSS 伪类和伪元素( : 与 ::) 区别 #3

oliver1204 opened this issue Dec 9, 2016 · 0 comments

Comments

@oliver1204
Copy link
Owner

oliver1204 commented Dec 9, 2016

简而言之:

  • 伪类,会对现有的元素进行筛选。
  • 伪元素,会创造出不存在的新元素。

在 CSS2 时代,伪元素和伪类均是以一个冒号开头的;在 CSS2.1 之后,为了对伪元素和伪类加以区分,规定伪类继续以一个冒号开头,而伪元素改为以两个冒号开头。但是为了向前兼容,浏览器同样接受 CSS2 时代已经存在的伪元素(它们包括:before, :after, :first-line, :first-letter)的单冒号写法。但是对于 CSS2 之后所有新增的伪元素(例如::selection),必须采用双冒号写法。

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

No branches or pull requests

1 participant