在IE中需要通过"filter"来定义透明度"opacity",而在Mozilla中是可以直接解析"opacity",所以如果要使得这个效果在两种浏览器中都得到支持,需要把两种设定都加进去。 看一段代码:
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title ></ title >
< style > ...
.highlightit img{...}{
/**//*ie 用*/
filter:Alpha(opacity=50);
/**//*ff 用*/
opacity: 0.5;
}
.highlightit:hover img{...}{
/**//*ie 用*/
filter:Alpha(opacity=100);
/**//*ff 用*/
opacity: 1;
}
</ style >
</ head >
< body >
< a class ="highlightit" href ="#" >< img border ="0" src ="http://sixteen520.cn/img/ban.jpgif" /></ a >
</ body >
</ html >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title ></ title >
< style > ...
.highlightit img{...}{
/**//*ie 用*/
filter:Alpha(opacity=50);
/**//*ff 用*/
opacity: 0.5;
}
.highlightit:hover img{...}{
/**//*ie 用*/
filter:Alpha(opacity=100);
/**//*ff 用*/
opacity: 1;
}
</ style >
</ head >
< body >
< a class ="highlightit" href ="#" >< img border ="0" src ="http://sixteen520.cn/img/ban.jpgif" /></ a >
</ body >
</ html >