IE正在失去ClearType [英] IE is losing ClearType

查看:155
本文介绍了IE正在失去ClearType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些非常奇怪的事情!

I'm experiencing something really strange!

我有一个我用JS(jQuery)隐藏的div。
喜欢这个:

I have a div that I'm hiding with JS (jQuery). Like this:

$('#myDiv').hide();

然后当我像这样制作一个淡入淡出时:

Then when I make a fadeIn like this:

$("#myDiv").fadeIn('slow');

然后文本在IE中丢失ClearType但在FF中丢失。如果我使用fadeIn来进行切换,那么一切都很好。

then the text loses ClearType in IE but not in FF. If I go with toggle insted of fadeIn, then it's all fine.

IE是什么,有什么解决方案,因为它看起来很糟糕。
(我现在可能已经知道了ClearType)

What is IE up to and is there any solutions for it because it looks horrible. (I have ClearType on as you maybe understand at this point)

推荐答案

A快速搜索主题显示如下:

A quick search on the subject shows the following:

jQuery fadeIn / fadeOut IE cleartype故障

问题似乎是CSS过滤器属性不是自动删除。 此问题的最简单解决方案将手动删除:

The problem seems to be that the CSS "filter" attribute is not automatically removed. The most simple solution to this problem would be removing it manually:

$('#myDiv').fadeIn('slow', function() {
   this.style.removeAttribute('filter');
});

正如上面的博客文章所解释的那样,这是一个相当混乱的解决方案。

As the blog post above explains, this is a rather messy solution.

摘自博客文章,包括清洁解决方案解决此问题:

Excerpt from the blog post, including a cleaner solution to this problem:


这意味着每次我们
想要淡化一个元素,我们需要
删除filter属性,
使我们的代码看起来很乱。

This means that every single time we want to fade an element, we need to remove the filter attribute, which makes our code look messy.

一个简单,更优雅的解决方案是:
可以通过$ b的插件接口使用自定义
函数包装.fadeIn()和
.fadeOut()函数$ b jQuery。代码与
相同,但不是直接调用
的淡入淡出函数,而是调用
包装器。像这样:

A simple, more elegant solution would be to wrap the .fadeIn() and .fadeOut() functions with a custom function via the plugin interface of jQuery. The code would be exactly the same, but instead of directly calling the fade functions, we call the wrapper. Like so:



$('#node').customFadeOut('slow', function() { 
   //no more fiddling with attributes here
});




那么,你如何使用它?在
包含用于
添加功能的jQuery库之后,只需
包含以下代码。

So, how do you get this working? Just include the following code after you include the jQuery library for the added functionality.



(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);

这篇关于IE正在失去ClearType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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