我在(ff、chrome 等)浏览器中使用 style.opacity
。
在 (ie6,7,8) 中,我正在使用 style.filter
但不起作用。
下面是我所做的:
targetElement.style.filter = 'alpha(opacity=30)'; // targetElement is div
前面的代码仅在 ie9 中运行良好,但在 ie6,7,8 中不起作用。为什么?
最佳答案
据我所知,IE 6 和 7 没有 alpha 透明度滤镜。您可以通过为开始和结束设置相同的颜色来使用渐变滤镜作为解决方法/技巧。 MS 渐变滤镜可以处理具有 alpha 透明度的 RGB。
半透明,近乎黑色的背景(alpha channel 是前两位十六进制数字):
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#E5333333, endColorstr=#E5333333 );
-ms-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#E5333333, endColorstr=#E5333333 );
关于javascript - 在浏览器 ie6,ie7,ie8 中使用 style.filter 时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13311254/