问题
I am fading out, and in a div:
$('.formErrors').fadeTo('fast', 0);
$('.formErrors').fadeTo('slow', 1);
But when I do this in IE 8, it seems this bit of CSS:
.formErrors li { font-weight: bold; }
Is causing the text to come back quite distorted: (image below)
http://www.newmania.com/images/error.jpg
The HTML I am applying this to is:
<div class="formErrors">
There are errors in your submission. Please fix the following and try again:
<ul><li>Action is empty</li></ul>
</div>
It works fine in Firefox. Any ideas please?
回答1:
A common solution is to define a background color, if you don't already have an image:
http://jsbin.com/axapa
.formErrors {background-color:white;}
Another option is to use fadeIn
and fadeOut
: the animation is till ugly, but at least it ends up nicely: http://jsbin.com/aboxa
回答2:
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();
});
};
jQuery.fn.fadeOut = function(speed, callback) {
return this.animate({opacity: 'hide'}, speed, function() {
if (jQuery.browser.msie)
this.style.removeAttribute('filter');
if (jQuery.isFunction(callback))
callback();
});
};
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();
});
};
This code will override some fade properties in JQuery specific to IE. I was able to successfully get fadeTo to work properly in IE here: https://app.tekstme.com/signup/
回答3:
I know this thread is really old but i found a simple solution. Using background was not applicable for my case because i had a complex background behind text whose background had to be transparent. Anyway I found this one working pretty well (css code to add):
.formErrors{position:relative;}
回答4:
Using <!DOCTYPE html> fixed this issue for me in IE8. The text still looks blocky during the fade but afterwards it smoothes out
来源:https://stackoverflow.com/questions/1865806/jquery-fadeto-causing-pixelated-text-in-ie8-when-font-weight-bold