jQuery fadeIn fadeOut – IE8不会褪色

任何人都可以告诉我为什么.jpg不会在IE8中淡入淡出或淡出。 现在它只是消失和再现,没有不透明度的变化。 我在本地设置并在发布服务器上设置,奇怪的是图像在本地淡入淡出,只有当我去发布服务器时才停止淡出。

只是想知道我是否遗漏了某些人可以迅速帮助我摆脱困境的事情。

这是发布服务器上的gcRotateContent,如果我只是抛出一个图像并且淡入淡出它可以工作,由于某种原因它不适用于这个标记。

Meet John
Portrait of employee John.
Software Development Lead, Server Performance
“You will find no other company with the sheer breadth of technologies. The things you get to see and learn from other people are amazing.”

 
This is first content First
This is second content Second
This is third content Third
This shouldn't move.
function fadeContent() { $(".gcRotateContent").first().customFadeOut(500, function() { $(".gcRotateContent:hidden:first").customFadeIn(500) }); $(".gcRotateContent").first().appendTo($(".gcRotateContent").parent()); } $(".gcRotate").height(0); $(".gcRotateContent").each( function() { if ($(".gcRotate").height() < $(this).height()) { $(".gcRotate").height($(this).height()); } } ); $(".gcRotateContent").each(function() { $(this).css("display", "none") }); $(".gcRotate").hover(function() { window.clearInterval(timer) }, function() { timer = window.setInterval("fadeContent()", 2000) }); $(".gcRotateContent").first().show(0); var timer = window.setInterval("fadeContent()", 2000); (function($) { $.fn.customFadeIn = function(speed, callback) { $(this).fadeIn(speed, function() { if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter'); if (callback != undefined) callback(); }); }; $.fn.customFadeOut = function(speed, callback) { $(this).fadeOut(speed, function() { if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter'); if (callback != undefined) callback(); }); }; })(jQuery);

显然有一个解决方法!

只需将绝对/相对定位元素设置为以下css属性:

 opacity:inherit; filter:inherit; 

例如:

 

玩得开心,

奥马尔

我想通了,css设置位置:相对于图像,显然ie8不喜欢那样,是否有一个解决方法我想知道,搜索开始了。

我刚刚遇到这个问题,所有的css滴答都没有用。 fadeIn / Out适用于FF和Chrome,但在IE8中没有,该元素根本没有出现。 在IE7中,它们只是从隐形变为可见。

因此,为了解决我的问题,我只想在其他浏览器上保留fadeIn / Out,并使元素出现在IE8中。 解决方案是使用回调,如下所示:

 $(".elements").fadeIn("slow",function(){$(this).show()}): $(".elements").fadeOut("slow",function(){$(this).hide()}): 

这样我总是强迫我想要的结果。

对于快速和脏的修复(或者如果上面的建议不起作用,就像我的情况一样),您可以简单地用show / hide替换jQuery的fadeIn / fadeOut。 所以在html中做:

  

在IE hacks的一些javascript文件中(例如ieFixes.js)放:

 jQuery.fn.fadeIn = function() { this.show(); } jQuery.fn.fadeOut = function() { this.hide(); } 

如果您正在链接动画调用等,则必须稍微调整一下。

用div(相同大小)替换背景图像和淡入/淡出div。