颜色透明不在IE中工作

时间:2012-12-10 12:25:38

标签: html css

我可以在Firefox和Chrome中获得此功能。但在代码下方,文字显示在IE中。该文字不应显示。

<a target="_blank" href="#">edit</a> 
<style>
    a {
        background: url("../images/edit1.gif") no-repeat scroll 0 0 transparent;
        color: transparent !important;
      }
</style>

1 个答案:

答案 0 :(得分:2)

大多数情况下,IE 5-8不支持透明属性。但IE 9将支持它。

在搜索我的博客时,我找到了以下方法

.transparent {
/* Required for IE 5, 6, 7 */
/* ...or something to trigger hasLayout, like zoom: 1; */
width: 100%; 

/* Theoretically for IE 8 & 9 (more valid) */   
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=50);

/* Older than Firefox 0.9 */
-moz-opacity:0.5;

/* Safari 1.x (pre WebKit!) */
-khtml-opacity: 0.5;

/* Modern!
/* Firefox 0.9+, Safari 2?, Chrome any?
/* Opera 9+, IE 9+ */
opacity: 0.5;
}

.transparent {
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
} 

我在Blog 1Blog 2

中提到了这一点