javascript - 在浏览器 ie6,ie7,ie8 中使用 style.filter 时不起作用

标签 javascript css internet-explorer

我在(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/

相关文章:

javascript - amChart 上的拨款图表未给出预期的输出图

html - 通过 CSS 在弹出模式后面添加背景模糊

html - 为什么设备宽度在桌面浏览器上有效?

internet-explorer - 我可以仅对 <frame> 内的内容禁用 IE 兼容模式吗?

javascript - 为什么 if (element.innerHTML == "") 在 Firefox 中不起作用

FadeIn 和 FadeOut html 元素的 Javascript 函数 - 工作解决方案

javascript - 从 SQLite 检索图像并在 HTML 页面上显示图像 - JavaScript

javascript - IE 11 从空白区域选择文本时,光标不会立即更改

javascript - RegEx@JS : Why/[INPUT|TEXTAREA]/. 测试 ("DIV")提供 TRUE?

html - 保持元素始终居中,侧边文本位于左侧