【问题标题】:set opacity of background color of div that works in ie7设置在ie7中工作的div背景颜色的不透明度
【发布时间】:2012-10-02 10:16:52
【问题描述】:

我想设置 div 背景的不透明度。意味着我想要 div 的透明背景。因为支持 rgba,所以对于 chrome 和 firefox 等浏览器来说非常简单。

但是对于ie7,我不知道该怎么做。 “过滤器:阿尔法(不透明度= 50);”对我没用,因为我想要透明背景,而不是内容。

我也不希望将透明图像设置为背景。

我也尝试过 ::before 并应用“filter: alpha(opacity=50);”,但它在 ie 中也不起作用。

谢谢。

【问题讨论】:

  • 我认为你只需要平铺一张半透明的图像。

标签: html css


【解决方案1】:

使用透明图像作为 IE 的背景。这很烦人,但它是做你想做的事情的最佳方式,而不会被文本的不透明度所困扰。或者只是go mental with the filters...

.opacityTest{
    /* Fallback for web browsers that doesn't support RGBa */
    background: rgb(0, 0, 0);
    /* RGBa with 0.6 opacity */
    background: rgba(0, 0, 0, 0.6);
    /* For IE 5.5 - 7*/
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
    /* For IE 8*/
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";
}

【讨论】:

  • 致 OP:请注意,过滤器会严重影响 IE 的性能。总的来说,我认为 SpaceBeers 对透明图像的第一个建议是你最好的选择。
  • @chipcullen - 同意。这是最简单的选择。
【解决方案2】:
<style>
div
{
filter: alpha(opacity=50);
}
</style>

【讨论】:

    【解决方案3】:

    我认为您必须为 IE LTE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-01
      • 2011-04-14
      • 2018-06-21
      • 2014-01-24
      • 1970-01-01
      • 2012-03-08
      • 2013-02-05
      • 2011-12-22
      相关资源
      最近更新 更多