在使用PNG透明和不透明度时,ie7和ie8的剩余是透明的 [英] Surplus in ie7 and ie8 intead of being Transparent while using PNG transparent and opacity

查看:113
本文介绍了在使用PNG透明和不透明度时,ie7和ie8的剩余是透明的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用PNG透明和不透明度的项目但该区域在IE7和IE8中有剩余而不是透明,它是黑色的,有人可以帮助我吗?

I am developing a project that uses the PNG transparent and Opacity but, the area has a surplus in IE7 and IE8 instead of being transparent, it is black, can someone help me?

打印区域

谢谢

推荐答案

我有一个解决方案,之前在多个网站上使用过。

I have a solution for this, have used on multiple sites before.

只需在将html内容写入页面后运行此功能:

function fixPNGs(){
  if(jQuery.browser.msie && jQuery.browser.version < 9){ 
    var i;
    //alert(document.images.length);
    for(i in document.images){
      if(document.images[i].src){
        var imgSrc = document.images[i].src;
        if(imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG'){
        document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
        }
      }
    }   
  }
}

它只适用于img元素而不适用于背景图像。但是一旦应用,您可以淡入淡出图像并为您的心灵内容添加动画效果。我对一些雄心勃勃的动画经历了一些奇怪的副作用,但是90%的时间都很好。

It will only work on img elements and not background images. But once applied you can fade in and out images and animate to your hearts content. I have experienced some strange side effect on some ambitious animations but for 90% of the time it's fine.

希望这对你有帮助!

W。

这篇关于在使用PNG透明和不透明度时,ie7和ie8的剩余是透明的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆