after和:: after之间有什么区别? [英] What is the difference between :after and ::after?
问题描述
它说的区别是:after是CSS2,while :: after是CSS3。有没有更重要的区别?
It says the difference is that :after is CSS2, while ::after is CSS3. Are there any more important differences?
(我试过Googling,但冒号似乎抛弃了搜索)
(I've tried Googling, but the colons seem to throw off the search)
推荐答案
伪元素在CSS2中用单个冒号表示,但在CSS3中被改变以建立伪类和伪元素之间的区别。出于兼容性考虑,CSS 1和CSS2中定义的伪元素仍允许使用单个冒号。
Pseudo-elements were denoted with a single colon in CSS2, but have been changed in CSS3 "in order to establish a discrimination between pseudo-classes and pseudo-elements". For compatibility reasons a single colon is still allowed for the pseudo-elements defined in CSS 1 and CSS2.
5.12.3:before和:after伪元素
':before'和':after'伪元素可用于在元素内容之前或之后插入生成的内容。
5.12.3 The :before and :after pseudo-elements
The ':before' and ':after' pseudo-elements can be used to insert generated content before or after an element's content.
CSS3 < a>
CSS3
7。伪元素
[...]
7. Pseudo-elements
[...]
伪元素由两个冒号c $ c> :: ),后跟伪元素的名称。
A pseudo-element is made of two colons (::
) followed by the name of the pseudo-element.
这个 ::
符号是由当前文档引入的,以便建立伪类和伪 - 元素。 为了与现有样式表兼容,用户代理还必须接受CSS级别1和2中引入的伪元素的前一个冒号符号(即:first-line,:first-letter,:before和:after )。此兼容性不允许用于本规范中引入的新伪元素。
This ::
notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in this specification.
这篇关于after和:: after之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!