IE7和Firefox支持PNG图片的透明效果,IE6不支持,不过可以通过AlphaImageLoader滤镜来解决。
一个例子:
运行示例
一个例子:
<!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>Background using PNG</title>
<style type="text/css">
body {
background:url(bodyBg.jpg) repeat-x;
}
a {
text-decoration:none;
color:#333333;
}
a:hover {
color:#999999;
}
/* For IE7 and Firefox */
html>body #wrap {
width:600px;
height:400px;
border:1px solid #ccc;
background-image:url(transparent.png);
}
/* End For IE7 and Firefox */
/* For IE6 Only */
*html #wrap {
width:600px;
height:400px;
border:1px solid #ccc;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src="transparent.png");
}
/* End For IE6 Only */
#content {
position:relative; /* AlphaImageLoader滤镜会导致该区域的链接和按钮无效,将position设置为relative可以解决该问题 */
}
</style>
</head>
<body>
<div id="wrap">
<div id="content"> <a href="http://www.google.cn">Google</a> <span>abcde</span></div>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Background using PNG</title>
<style type="text/css">
body {
background:url(bodyBg.jpg) repeat-x;
}
a {
text-decoration:none;
color:#333333;
}
a:hover {
color:#999999;
}
/* For IE7 and Firefox */
html>body #wrap {
width:600px;
height:400px;
border:1px solid #ccc;
background-image:url(transparent.png);
}
/* End For IE7 and Firefox */
/* For IE6 Only */
*html #wrap {
width:600px;
height:400px;
border:1px solid #ccc;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src="transparent.png");
}
/* End For IE6 Only */
#content {
position:relative; /* AlphaImageLoader滤镜会导致该区域的链接和按钮无效,将position设置为relative可以解决该问题 */
}
</style>
</head>
<body>
<div id="wrap">
<div id="content"> <a href="http://www.google.cn">Google</a> <span>abcde</span></div>
</div>
</body>
</html>
运行示例