什么是伪元素? [英] What is a pseudo element?
问题描述
我解释这个非常漂亮的例子,CSS如何可以帮助你在图像上创造出美好的发光效果。
I'm dissecting this very beautiful example of how CSS can help you create nice glow effects on images.
http://jsfiddle.net/necolas/KbNq7/
提到:
虽然这种方法只会在Firefox 4中产生全效果,但其他浏览器最终会赶上并应用转换到
伪元素。
什么是伪元素?
推荐答案
伪元素是以特殊方式处理元素的某些部分的CSS选择器。
Pseudo-elements are CSS selectors that manipulate parts of an element in a special way.
包括:
-
:第一行
-
:之前
-
:
:first-line
:before
:after
伪元素应用如下
p:first-letter{
color:black;
font-style:italic;
}
注意: :
后跟选择器是如何在CSS1和CSS2中表示伪元素。在CSS3中,使用双冒号( ::
)将它们与伪类区分开。
Note: the :
followed by the selector is how pseudo elements are denoted in CSS1 and CSS2. In CSS3, the double colon is used (::
) to distinguish them from pseudo-classes.
这里: http://reference.sitepoint.com/css/pseudoelements
支持一些浏览器,IE的旧版本支持度很低。 QuirksMode有一个兼容性表(有点过时,但仍然有用): http://www.quirksmode。 org / css / contents.html#t15
Support is decent for a number of browsers, with older versions of IE notably poor with support. QuirksMode has a compatibility table (a bit out-of-date but still useful): http://www.quirksmode.org/css/contents.html#t15
伪元素可以做一些很酷的东西,包括
Pseudo elements can do some cool things, including
- 显示打印文档中链接的网址
- fake a
float:center;
- show the URLs of links in printed docs
- fake a
float:center;
在这里查看更多:http://css-tricks.com/9516-pseudo-element-roundup/
jQuery有一些独特的选择器
,可以增强和扩展原生CSS组:
jQuery has a number of unique selectors
that enhance and expand on the native CSS group:
http://api.jquery.com/category/selectors/
注意:您可以使用jQuery强制旧版浏览器采用某些规则。例如,IE6将忽略:last-child
。使用jQuery可以强制IE6应用该样式。
Note: you can use jQuery to force older browsers to adopt certain rules. For example, IE6 will ignore :last-child
. Using jQuery can force IE6 to apply that style.
http://www.w3.org/TR/CSS2/selector.html#pseudo-element-selectors
这篇关于什么是伪元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!