: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
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
