在网页中插入一个透明背景的PNG图片
2012-09-05 14:42
453 查看
在网页中插入一个透明背景的PNG图片,可是在显示的时候,它的背景就成灰色了。这是IE的bug。需要加入以下代码:
<script language="jscript"> function correctPNG() { for(var i=0; i<document.images.length; i++) { var img = document.images 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> 透明Flash动画设置参数为:参数为wmode 值为transparent
相关文章推荐
- 以Png图片在网页中背景透明问题展开谈png图片格式问题
- IE6中对于插入的透明背景的.png的图片有灰色背景的解决方案
- 有关ie6下PNG图片背景不透明的一个js的解决办法
- 网页中PNG透明背景图片的完美应用
- Google图片存储格式WebP增加与PNG类似背景透明效果
- 处理网页中png的透明背景
- 使用分层窗口及透明png图片实现一个异形窗口
- 分享一个支持在IE6中PNG图片透明插件
- 完美解决ie6不支持png 透明图片 和标签背景的问题
- img 标签导入png图片背景设置透明
- 将多个背景集成到一个png图片上CSS定位
- JS脚本(控制IE6下Png图片背景透明)
- J2ME 背景透明的PNG图片 怎么弄?
- thinkPHP3.2上传透明背景,png图片出现白底解决办法
- ie6下使作为背景图片的PNG透明
- IE6显示PNG图片背景透明的解决方法
- IE6显示png透明背景、图片的方法
- 网页上PNG透明图片的运用(ie6+滤镜)
- ie6下使网页png图片不透明显示解决办法
- IE6下PNG透明图片背景显示灰色的完美解决方法