jQuery的周期IE7透明PNG问题 [英] jquery cycle IE7 transparent png problem

查看:115
本文介绍了jQuery的周期IE7透明PNG问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了麻烦jQuery的周期时,我有透明的PNG文件工作在IE7

I'm having trouble getting jquery cycle to work when I have transparent png files in IE7

这是罚款的Firefox和Chrome,但在IE浏览器(第7版),我得到一个黑色的地方
巴布亚新几内亚透明度渐变过程。

It's fine in Firefox and Chrome but in IE (version 7) I get a black colour where the png transparency is during the fade.

这能作出的工作吧?

推荐答案

不幸的是,虽然IE7支持透明的PNG的,只有一个过滤器可以同时被应用到的元素

unfortunately, though IE7 supports transparent PNG's, only one filter can be applied to an element at a time.

在哪些应用程序正在发生的是IE7的应用alpha滤镜你PNG,然后由jQuery的要求申请另一个alpha滤镜的褪色。像你说的这有明显的效果。

What is happening in your application is that IE7 is applying the alpha filter to your PNG, and is then asked by jQuery to apply another alpha filter for the fade. This has visible results like you said.

要解决这个问题的方法是窝一个容器内的PNG,然后褪色的容器。排序是这样的:

The way to get around this is to nest your png inside a container and then fade the container. Sort of like this:

<div id="fadeMe">
    <img src="transparent.png" alt="" />
</div>

要解决这个问题的另一种方式是,我用,因为我不能改变结构这个简单的jQuery插件。我会给归属,但老实说,我不记得在那里我找到了。

Another way to get around this is this simple jQuery plugin that i used because i couldn't change the structure. I would give attribution but I honestly cant remember where i found it.

/* IE PNG fix multiple filters */
(function ($) {
    if (!$) return;
    $.fn.extend({
    	fixPNG: function(sizingMethod, forceBG) {
    		if (!($.browser.msie)) return this;
    		var emptyimg = "empty.gif"; //Path to empty 1x1px GIF goes here
    		sizingMethod = sizingMethod || "scale"; //sizingMethod, defaults to scale (matches image dimensions)
    		this.each(function() {
    			var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"),
    				imgname = (isImg) ? this.src : this.currentStyle.backgroundImage,
    				src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
    			this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
    			if (isImg) this.src = emptyimg;
    			else this.style.backgroundImage = "url(" + emptyimg + ")";
    		});
    		return this;
    	}
    });
})(jQuery);

注意最初插件写来修复IE6 PNG透明度,但我修改了它在IE6 +你的问题的工作。

NOTE Originally the plugin was written to fix PNG transparency in IE6 but I modified it to work with your problem in IE6+.

旁注:我不记得了我的头顶,但我认为,IE8可能有同样的问题。纠正我,如果我错了:)

Sidenote: I cant remember off the top of my head but i think that IE8 may have the same problem. Correct me if i'm wrong :)

这篇关于jQuery的周期IE7透明PNG问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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