使用IE6的滤镜来解决
background: url(你的图.png) no-repeat; _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’你的图.png’); /* IE6 注意这里的png路径最好是绝对路径,因为它是相对于调用的html页面的路径,而不是css目录的相对路径 */ _background-image: none;
JS解决IE6下PNG图片不透明的问题
背景png图片可以使用css来解决,如果是img 标签的图片,我则是用js来实现,也比较简单。
以下是网上流行的pngfix.js的代码。
1.插件下载地址 function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. { var arVersion = navigator.appVersion.split("MSIE") var version = parseFloat(arVersion[1]); if ((version >= 5.5) && (document.body.filters)) { for(var j=0; j<document.images.length; j++) { var img = document.images[j]; 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 j = j-1 ; } } } } window.attachEvent && window.attachEvent("onload", correctPNG);jQuery插件解决IE6下PNG图片不透明的问题
Download jQuery
Download pngFix.zip jquery.pngFix.js
2.使用方法<script type="text/javascript" src="jquery-latest.pack.js"></script> <script type="text/javascript" src="jquery.pngFix.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(document).pngFix(); }); </script>
来源:http://www.002pc.com/master/College/Page/Skills/19049.html


关于《IE6下img标签PNG图片背景不透明的问题》文章的评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面