IE8 伪元素 Bug
我在 IE8 中发现了一个关于 CSS :before
和 :after
伪元素的奇怪问题。当您将一个伪元素位置设置为绝对位置而将另一个伪元素位置设置为相对位置时,就会出现此问题;请参阅以下示例:
<style type="text/css">
div:before { content: ""; position: relative; }
div:after { content: ""; position: absolute; }
</style>
<div>stuff</div>
IE8 崩溃。字面上地。没有错误,没有任何帮助 - 只是可怕的“Internet Explorer 已停止工作”并且 Windows 7 尝试重新启动它。需要明确的是,切换到IE8浏览器和IE9渲染模式时会出现错误。当我在 IETester 的 IE8 页面中加载示例时,没有发生错误。
我会尽快在实际的 IE8 中测试这一点,但我的问题是:为什么会发生这种情况?是IE8的bug吗?也许是某种 position
错误的副作用? IE8不是应该渲染伪元素吗?
I've isolated a strange issue with IE8 regarding the CSS :before
and :after
pseudo elements. The issue occurs when you set one pseudo elements position to absolute and the other's to relative; see the following example:
<style type="text/css">
div:before { content: ""; position: relative; }
div:after { content: ""; position: absolute; }
</style>
<div>stuff</div>
IE8 crashes. Literally. No error, nothing helpful - just the dreaded "Internet Explorer has stopped working" and the Windows 7 attempt to relaunch it. To be clear, the error occurs when switching to the IE8 Browser and Rendering Mode of IE9. When i loaded the example in IETester's IE8 page, no error occurred.
I will test this in an actual IE8 asap, but my question is: why does this happen? Is it an IE8 bug? Maybe a side effect of some sort of position
bug? Isn't IE8 supposed to render pseudo elements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这很奇怪。如果你在
div:before
上设置float:left;
,我就能让它工作Yeah, that's weird. I was able to get it to work if you make it
float:left;
on thediv:before
我知道这个问题很老了..但我遇到了同样的问题并用“div::after”而不是“div:after”修复了它
I know this question is old.. but I had the same problem and fixed it with "div::after" instead of "div:after"