有没有办法让 IE8 尊重 `:before` 伪元素的不透明度?
我有这个简单的 CSS...
div:before {
content: "G'day";
filter: alpha(opacity=40);
-moz-opacity: .4;
opacity: .4;
}
:before
伪元素在 Firefox 6 中具有正确的不透明度。在 IE8 中,不应用不透明度。
通常,在 div
上设置不透明度是可行的,但事实并非如此我想要什么。
我尝试添加 display: block
但没有帮助。
虽然我可以解决这个问题,但有什么技巧可以让 IE8 遵守 :before
(和 :after
就此而言)伪元素?
I have this simple CSS...
div:before {
content: "G'day";
filter: alpha(opacity=40);
-moz-opacity: .4;
opacity: .4;
}
The :before
pseudo element has the correct opacity in Firefox 6. In IE8, the opacity is not applied.
Typically, setting the opacity on the div
works, but that isn't what I want.
I tried adding display: block
but it didn't help.
Whilst I could workaround this, is there any trick to get IE8 to honour the opacity
property on a :before
(and :after
for that matter) pseudo element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是不可能的。
不久前我遇到了同样的问题,最后我只是解决了这个问题(不使用
:before
)。以下是一些关于为什么这是不可能的合理推理:为什么过滤器伪元素上的渐变在 IE8 中不起作用?
I don't think it's possible.
I had the same problem a while back, and I ended up just working around it (by not using
:before
).Here's some sound reasoning as to why it's not possible: Why does a filter gradient on a pseudo element not work in IE8?