:after 与 ::after

时间:2022-12-17
本文介绍了: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:为什么浏览器会限制 :visited 选择器? 下一篇:选择器“.class.class"有什么区别?和“.class .c

相关文章

最新文章