文章标签 ‘兼容’
#z_2 {
background:url(../images/new_listing/color_black.gif) no-repeat;
filter:alpha(opacity=80);
-moz-opacity:0.80;
opacity:0.80;
}
兼容IE,FF背景图片透明css代码说明:
filter:alpha(opacity=80);支持IE
-moz-opacity:0.80; 支持FF
opacity:0.80;支持w3c标准
*+html 与 *html 是IE特有的标签, firefox 暂不支持,而*+html 又为 IE7特有标签。因此便可以很方便的得到一个针对于
FireFox、IE6、IE7三种不通浏览器的hack实例代码如下:
<html>
<head>
<style>
#wrapper { width: 120px;height:100px; background:#ff0; } /* FireFox */
*html #wrapper { width: 80px;} /* ie6 fixed */
*+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */
</style>
</head>
<body>
<div id=”wrapper”></div>
</body>
</html>
2.IE6能识别*,但不能识别 !important,IE7能识别*,也能识别!important;FF不能识别*,但能识别!important;因此也可以写出一个针对于
FireFox、IE7、IE6三种不通浏览器的hack实例代码如下:
<html>
<head>
<style>
#wrapper { width: 120px;*width: 60px !important;*width: 80px;height:100px;
background:#ff0;}
/*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/
</style>
</head>
<body>
<div id=”wrapper”></div>
</body>
</html>
3.还有可以利用的是ie6.0支持下划线(即”_”),因此也能写出一个针对于
FireFox、IE7、IE6三种不通浏览器的hack实例代码如下:
<html>
<head>
<style>
#wrapper { width: 120px;*width: 60px;_width: 80px;height:100px; background:#ff0;}
/*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/
</style>
</head>
<body>
<div id=”wrapper”></div>
</body>
</html>
当然hack远不止这些,只要了解属性在各浏览器中不同的解析原理或是能否识别,再加以组合就可以是一套用来解决浏览器兼容性的hack.
