【问题标题】:jQuery fadeIn fadeOut Text looks bad in Internet Explorer IE: getting the fix to workjQuery fadeIn fadeOut Text 在 Internet Explorer IE 中看起来很糟糕:修复工作
【发布时间】:2011-06-11 08:35:29
【问题描述】:

我已经尝试过之前在此处(和其他地方)发布的解决方案,用于在 Internet Explorer IE 中的 jQuery 淡入和淡出期间看起来像素化和糟糕的文本。

两种解决方案似乎很常见:添加背景颜色或删除“过滤器”属性。

通过这种设计,我无法使用背景颜色修复(这有助于但并不能完全消除问题)。

所以我一直在尝试“在淡入淡出后删除过滤器属性”修复。 但它不会修复文本,并且“removeAttribute”版本会停止脚本。 你们是如何让它工作的?

我的jQ代码如下。

感谢您考虑这个问题!

======================================

// 这个循环是基于 Pointy 的另一个 Stackoverflow 答案

    var divs = $('.myDiv'), i = 0;
    function reveal() {
        if (i == divs.length) divs.fadeIn(inTime, function(){           
            $('.mainPadding').css("height", "4000px"); 
            }); 
        divs.eq(i).fadeIn(inTime, function(){
               //$(this).style.removeAttribute('filter');
               $(this).removeAttr("filter");
            }).delay(waitTime).fadeOut(outTime, function() {
                i++; 
                setTimeout(reveal, 0);
          });
    }
    setTimeout(reveal, 0);   

【问题讨论】:

    标签: jquery internet-explorer


    【解决方案1】:

    这是我发现的...


    // When fading a html node with the .fadeIn() and .fadeOut() // functions in jQuery, IE drops the windows Cleartype rendering; // which results in very ugly text. This override corrects that problem

        jQuery.fn.fadeTo = function(speed, to, callback) {
            return this.animate({ opacity: to }, speed, function() {
                if (to == 1 && jQuery.browser.msie)
                    this.style.removeAttribute('filter');
    
                if (jQuery.isFunction(callback))
                    callback();
            });
        };
    

    【讨论】:

    • 谢谢 John K。在jquery.malsup.com/fadetest.html 找到了类似的东西,但它也没有修复 IE 中的问题,仍然在处理这个问题。 jQuery.fn.fadeIn = function(speed, callback) { return this.animate({opacity: 'show'}, speed, function() { if (jQuery.browser.msie) this.style.removeAttribute('filter') ; if (jQuery.isFunction(callback)) callback(); }); }; [...重复淡出]
    • 好吧,我已经尝试将这些覆盖放在 html 页面和 jQuery 文件本身的末尾。但到目前为止,它在 IE 中没有任何区别。是否必须放置此代码才能使其工作的特殊位置?再次感谢您在这里提供帮助,不胜感激。
    • 我不确定...看起来如果您将它放在 html 页面本身中,那会起作用...您是否尝试过在 IE 中使用开发人员工具或在 Firefox 中对其进行调试?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2017-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多