: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
基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
