:after vs. ::after(:after 与 ::after)
问题描述
CSS 2.1 :after
和 CSS 3 ::after
伪选择器(除了 ::after
旧版浏览器不支持)?是否有任何实际理由使用新规范?
Is there any functional difference between the CSS 2.1 :after
and the CSS 3 ::after
pseudo-selectors (other than ::after
not being supported in older browsers)? Is there any practical reason to use the newer specification?
推荐答案
这是伪类 vs 伪元素的区别.
It's pseudo-class vs pseudo-element distinction.
::first-line
、::first-letter
、::before
和 ::after
除外code>(已经存在了一段时间,如果您需要 IE8 支持,可以与单冒号一起使用),伪元素 需要双冒号.
Except for ::first-line
, ::first-letter
, ::before
and ::after
(which have been around a little while and can be used with single colons if you require IE8 support), pseudo-elements require double colons.
Pseudo-classes 选择实际元素本身,可以使用 :first-child
或 :nth-of-type(n)
进行例如,选择 div 中的第一个或特定 <p>
.
(还有实际元素的状态,例如 :hover
和 :focus
.)
Pseudo-classes select actual elements themselves, you can use :first-child
or :nth-of-type(n)
for selecting the first or specific <p>
's in a div, for example.
(And also states of actual elements like :hover
and :focus
.)
Pseudo-elements 以元素的子部分为目标,例如 ::first-line
或 ::first-letter
,本身不是元素.
Pseudo-elements target a sub-part of an element like ::first-line
or ::first-letter
, things that aren't elements in their own right.
实际上,更好的描述在这里:http://bricss.net/post/10768584657/know-your-lingo-pseudo-class-vs-pseudo-element
也在这里:http:///www.evotech.net/blog/2007/05/after-v-after-what-is-double-colon-notation/
Actually, better description here: http://bricss.net/post/10768584657/know-your-lingo-pseudo-class-vs-pseudo-element
Also here: http://www.evotech.net/blog/2007/05/after-v-after-what-is-double-colon-notation/
这篇关于:after 与 ::after的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为::after 与 ::after


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01