为何透明图片IE6下有阴影
来源:互联网 发布:wechat mac download 编辑:程序博客网 时间:2024/04/30 01:35
1.涉及web前端网页开发,常常遇到浏览器兼容问题。对于IE不同版本的浏览器在css样式上会有所区别:下面举例说明png格式图片兼容问题。
下面是非IE6显示效果:
下图是IE6上显示效果:
登录框png格式透明的图片,如不加处理直接在IE6下会出现灰色阴影,效果非常难看。
解决方法
方法一、也是最笨的办法,将图片换成gif或jpg格式的。(但是这样效果可能不及png)
方法二、在该jsp页面的中加入下面js代码
<script type="text/javascript">
//correntPNG alphaBackgrounds这两个方法用于解决ie6 对png格式的透明图片背景变灰的问题
function correctPNG()
{
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 ;
}
}
}
}
function alphaBackgrounds(){
var rslt = navigator.appVersion.match(/MSIE (d+.d+)/,'');
var itsAllGood = (rslt != null && Number(rslt[1]) >=5.5);
for(i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (bg){
if (bg.match(/.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ mypng + "', sizingMethod='crop')";
document.all[i].style.backgroundImage = "url('')";
}
}
}
}
if(navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent){
window.attachEvent("onload",correctPNG);
window.attachEvent("onload",alphaBackgrounds);
window.attachEvent("onload", correctPNG);
window.attachEvent("onload", alphaBackgrounds);
}
</script>
- 为何透明图片IE6下有阴影
- ie6下PNG图片透明
- png图片ie6下背景透明
- IE6 下的PNG透明图片
- 解决IE6下透明PNG图片有灰底
- IE6下PNG插入图片透明
- IE6下显示透明的PNG图片
- png图片在ie6下透明效果
- 透明图片在IE6下显示问题
- 令ie6下PNG图片显示透明
- IE6下PNG图片透明解决办法
- ie6下png图片变透明解决方案
- ie6下透明图片的问题
- IE6下png图片透明问题
- IE6下使PNG图片透明
- IE6支持透明图片
- ie6图片透明
- ie6 png图片透明
- android include标签的使用,在RelativeLayout中使用include标签需注意!!!!!
- 16、高级工具页面设计
- 计算机书籍小结
- 基于jquery的搜索自动填充功能jquery.autocomplete.min.js插件的引用
- iPhone如何打包成一个通用的静态库文件(模拟器和真机都可以用)
- 为何透明图片IE6下有阴影
- 敏捷开发之极限编程过程
- Linux下diff,Patch的应用和制作方法介绍
- 浅谈随机游走
- c++对象池
- Google云计算GFS+MapReduce
- ant异常整理-错误: 非法字符: \65279 .
- 对比、对齐、重复、亲密性
- win8安装.net3.5