设置在ie7中工作的div的背景颜色的不透明度

Par*_*rth 2 html css

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

但对于ie7,我不知道该怎么做."filter:alpha(opacity = 50);" 对我没用,因为我想要透明的背景,而不是内容.

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

我也试过:: before并应用"filter:alpha(opacity = 50);",但它也没有在ie中工作.

谢谢.

Spa*_*ers 6

使用透明图像作为IE的背景.这很烦人,但它是做你想做的最好的方式,而不会在文本上遇到不透明.或者只是过滤精神过滤器 ......

.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)";
}
Run Code Online (Sandbox Code Playgroud)