2012-10-02 64 views
2

我想设置div背景的不透明度。意味着我想要div的透明背景。浏览器非常简单,例如chrome & firefox,因为支持rgba。设置在ie7中工作的div背景颜色的不透明度

但对于IE7,我不知道该怎么做。 “filter:alpha(opacity = 50);”对我没有用处,因为我想要透明背景,而不是内容。

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

我也试过::之前和应用“过滤器:alpha(opacity = 50);”,但它也不在ie中工作。

谢谢。

+0

,我认为你必须要平铺半透明图像。 – ratbum

回答

6

为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)"; 
} 
+1

对于OP:只是预先警告过滤器在IE中会出现严重的性能下降。我认为SpaceBeers对透明图像的第一个建议是最好的选择。 – chipcullen

+0

@ chipcullen - 同意。这是最简单的选择。 – SpaceBeers

0
<style> 
div 
{ 
filter: alpha(opacity=50); 
} 
</style> 
0

我认为你将不得不使用一个透明的背景图像IE LTE < 7(有一些有条件的意见/ CSS)