:after vs. :: after [英] :after vs. ::after
问题描述
CSS 2.1 :之后
和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?
推荐答案
这是伪 class vs pseudo- 元素。
It's pseudo-class vs pseudo-element distinction.
除了 ::一行
, :: first-letter
, :: before
和 :: after
已经有一段时间了,如果您需要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.
伪类自己选择实际元素,您可以使用:first-child
或:
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
.)
伪元素定位 :: 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 < a>
也在这里: 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 vs. :: after的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!