网页PNG透明支持(下测试通过)_明人的IT技术实验室
来源:百度文库 编辑:神马文学网 时间:2024/04/29 09:05:56
网页PNG透明支持(IE6、IE7、firefox下测试通过)2007-11-15 16:17 IE6不支持PNG半透明图片的缺陷为web设计带来了极大的不便,之前曾经介绍过用滤镜+hack的方法实现显示PNG,不过实现起来相当繁琐。还有一种网上比较流行的方法,更加简便,下面详细介绍这种方法:
把以下代码保存为correctpng.js function correctPNG()
{
for(var i=0; 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 = " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">"
img.outerHTML = strNewHTML
i = i-1
};
};
};
if(navigator.userAgent.indexOf("MSIE")>-1)
{
window.attachEvent("onload", correctPNG);
};
在网页的头部引用一下
使用的时候直接用img标签即可。
把以下代码保存为correctpng.js function correctPNG()
{
for(var i=0; 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 = " + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\">"
img.outerHTML = strNewHTML
i = i-1
};
};
};
if(navigator.userAgent.indexOf("MSIE")>-1)
{
window.attachEvent("onload", correctPNG);
};
在网页的头部引用一下
使用的时候直接用img标签即可。
网页PNG透明支持(下测试通过)_明人的IT技术实验室
网页PNG透明支持
让IE6支持png 透明的多种解决
让IE6支持png 透明的多种解决方法1
让IE6支持png 透明的多种解决方法1111
IE6下PNG背景透明
png透明
算法分析与设计之五大常用算法_算法_C/C++频道_中国IT实验室技术专题
通过XDoclet定制模板进行快速开发|中国IT实验室
常见排序算法的实现_排序算法_中国IT实验室专题
Linux下常见文件格式的压缩、解压小结 ---中国IT实验室
显微镜微测尺的使用 - 金相实验室 - 实验技术论坛 =实验测试、实验论坛、实验技术、实验...
png透明解决办法
png透明解决办法
png透明解决办法dsf
png透明解决办法11
png透明解决办法hhhh
png透明解决办法gggg
png透明解决办法3
png透明解决办法4
怎么去除桌面图标下的蓝色方块?_电脑达仔(欢迎Windows7)IT知名博客 知识 技术 ...
游戏下载安装的基本知识_电脑达仔(欢迎Windows7)IT知名博客 知识 技术 学习 下...
WIN7下任务栏显示星期的方法_电脑达仔(欢迎Windows7)IT知名博客 知识 技术 ...
用两台电脑通过一个网口同时上网_电脑达仔(欢迎Windows7)IT知名博客 知识 技术 ...