IE9 是否支持 CSS3 ::before 和 ::after 伪元素?
在此 MS 兼容性表上,它说,IE9不支持伪元素 ::before
和 ::after
,但当我尝试时似乎确实如此......参见 JSBin
我做错了什么吗?我认为 ::before
和 ::after
是向 IE9 隐藏内容的好工具,但事实上,它们不是。
On this MS compatibility table it says, IE9 does not support pseudo-elements ::before
and ::after
, but when I try it seems it does... see JSBin
Am I doing something wrong? I thought ::before
and ::after
would be nice tools to hide stuff from IE9, when in fact, they don't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CSS2 伪元素
:before
和:after
使用传统的单冒号表示法,由 IE8 及更高版本支持。他们对 CSS3 并不陌生。另一方面,双冒号表示法是 CSS3 的新内容。 IE9 确实支持
::before
和::after
,同样适用于 CSS1 伪元素::first-line
和::first-letter
。然而,今后,任何新的伪元素都不能使用单冒号语法,并且浏览器(包括 IE)预计将支持所有伪元素的双冒号语法。我不知道为什么该表说 IE9 不支持新的伪元素语法,因为根据上面链接的各个选择器的文档以及您的测试用例,它确实支持新的伪元素语法。当然,还有这个答案。
The CSS2 pseudo-elements
:before
and:after
, with the traditional single-colon notation, are supported by IE8 and later. They are not new to CSS3.The double-colon notation, on the other hand, is new to CSS3. IE9 does support this new notation for
::before
and::after
, and likewise for the CSS1 pseudo-elements::first-line
and::first-letter
. Going forward, however, no new pseudo-element may use the single colon syntax, and browsers (including IE) are expected to support the double colon syntax for all pseudo-elements.I have no clue why that table says IE9 doesn't support the new pseudo-element syntax, because it certainly does according to the docs for the individual selectors linked above, and your test case. As well as, of course, this answer.
IE 9 在“标准模式”下支持
::after
和::before
(带有两个冒号)符号。在“怪异模式”下,情况并非如此。可以按如下方式进行测试:这里 CSS 规则被忽略,因为 IE 9 进入怪异模式。但是,如果您在一开始添加以下行,IE 9 就会进入标准模式,并且 CSS 规则生效:
在 IE 9 中, 怪异模式,不支持新的 CSS 功能(大多数既不在 CSS 2.1 中也不在 IE 旧版本中的功能)。在怪异模式下,IE 9 也不支持旧的单冒号符号
:after
和:before
。它在“IE 8 模式”下支持它们(但不支持两个冒号版本),您可以在开发人员工具 (F12) 中手动选择、在“文档模式”菜单中或使用标签< 在文档级别选择;meta http-equiv="X-UA-Compatible" content="IE=8">
。IE 9 supports the notations
::after
and::before
(with two colons) in “standards mode”. In “quirks mode”, it does not. This can be tested e.g. as follows:Here the CSS rule is ignored, because IE 9 goes to quirks mode. But if you add the following line at the very start, IE 9 goes to standards mode and the CSS rule takes effect:
It is common in IE 9 that in quirks mode, new CSS features (most features that are neither in CSS 2.1 or in the IE legacy) are not supported. In quirks mode, IE 9 does not support the old one-colon notations
:after
and:before
either. It supports them (but not the two-colon versions) in “IE 8 mode”, which you can select in developer tools (F12) manually, in the “document mode” menu, or at document level using the tag<meta http-equiv="X-UA-Compatible" content="IE=8">
.引用自 http://www.w3.org/community/webed/wiki/Advanced_CSS_selectors< /a>
As quoted from http://www.w3.org/community/webed/wiki/Advanced_CSS_selectors