|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
对于IE6不支持PNG-24背景透明这个问题可以说是很早就出现了的,,当然网上的各种解决方法也有很多。。
我在下面就讲两种比较常见的办法。如果大家想了解更多的方法可以去搜索一下。。
当然第一种方法是滤镜法:
- <html>
- <head>
- <title>er</title>
- <style type="text/css">
- html>body #png {background: url(images/logo.png) repeat;}
- html #png {
- filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src="images/logo.png");
- background:none;
- }
- </style>
- <SCRIPT type=text/javascript>
- function correctPNG()
- {
- for(var i=0; i<document.images.length; i++)
- {
- var img = document.images[i]
- var imgName = img.src.toUpperCase()
- if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
- {
- var imgID = (img.id) ? "id='" + img.id + "' " : ""
- var imgClass = (img.className) ? "class='" + img.className + "' " : ""
- var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
- var imgStyle = "display:inline-block;" + img.style.cssText
- if (img.align == "left") imgStyle = "float:left;" + imgStyle
- if (img.align == "right") imgStyle = "float:right;" + imgStyle
- if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
- var strNewHTML = "<span " + imgID + imgClass + imgTitle
- + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
- + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
- + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
- img.outerHTML = strNewHTML
- i = i-1
- }
- }
- }
- window.attachEvent("onload", correctPNG);
- </SCRIPT>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- </head>
- <body bgcolor="#FFffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
- <div id="png"> <img src="images/logo.png"></div>
- </body>
- </html>
复制代码
第二种方法是插件法:
这个代码是一个老外写的支持png图片的透明,背景定位。全搞定!!!!DD_belatedPNG_0.0.8a-min.js 用法:
- <!--[if lte IE 6]>
- <script src="DD_belatedPNG_0.0.8a.js" type="text/javascript"></script>
- <script type="text/javascript">
- DD_belatedPNG.fix('div, ul, img, li, input , a');
- </script>
- <![endif]-->
复制代码 将上边的代码放在<head>……</head>里面(当然其他位置也是可以的)下面是DD_belatedPNG_0.0.8a-min.js 的源文件
|
|