gpt4 book ai didi

JQuery 切换函数在 IE 中呈现奇怪的文本(丢失 ClearType?)

转载 作者:行者123 更新时间:2023-12-01 00:40:18 24 4
gpt4 key购买 nike

我有这个小脚本,可以在单击按钮时切换联系表单:

$(document).ready(function(){

$("#button").click(function () {
$("#form").toggle("slow");
});

});

在 Firefox 中一切正常,但在 IE 中,切换的淡入效果似乎没有 100% 完成,并且文本在完全渲染之前被“卡住”在某个地方,失去了所有的精分割辨率。

我读了这个topic但我不知道如何将其应用于我的问题。

感谢您的帮助。

最佳答案

这可能就是您正在寻找的。另外,还有一个functional demo of another similar method在线提供:

//-------------------------------------------------------------------------------------------------------
// ClearTypeFadeTo / ClearTypeFadeIn / ClearTypeFadeOut
//
// Custom fade in and fade out functions for jQuery that will work around
// IE's bug with bold text in elements that have opacity filters set when
// also using Window's ClearType text rendering.
//
// New Parameter:
// bgColor The color to set the background if none specified in the CSS (default is '#fff')
//
// Examples:
// $('div').ClearTypeFadeIn({ speed: 1500 });
// $('div').ClearTypeFadeIn({ speed: 1500, bgColor: '#ff6666', callback: myCallback });
// $('div').ClearTypeFadeOut({ speed: 1500, callback: function() { alert('Fade Out complete') } });
//
// Notes on the interaction of ClearType with DXTransforms in IE7
// http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx
(function($) {
$.fn.ClearTypeFadeTo = function(options) {
if (options)
$(this)
.show()
.each(function() {
if (jQuery.browser.msie) {
// Save the original background color
$(this).attr('oBgColor', $(this).css('background-color'));
// Set the bgColor so that bold text renders correctly (bug with IE/ClearType/bold text)
$(this).css({ 'background-color': (options.bgColor ? options.bgColor : '#fff') })
}
})
.fadeTo(options.speed, options.opacity, function() {
if (jQuery.browser.msie) {
// ClearType can only be turned back on if this is a full fade in or
// fade out. Partial opacity will still have the problem because the
// filter style must remain. So, in the latter case, we will leave the
// background color and 'filter' style in place.
if (options.opacity == 0 || options.opacity == 1) {
// Reset the background color if we saved it previously
$(this).css({ 'background-color': $(this).attr('oBgColor') }).removeAttr('oBgColor');
// Remove the 'filter' style to restore ClearType functionality.
$(this).get(0).style.removeAttribute('filter');
}
}
if (options.callback != undefined) options.callback();
});
};

$.fn.ClearTypeFadeIn = function(options) {
if (options)
$(this)
.css({ opacity: 0 })
.ClearTypeFadeTo({ speed: options.speed, opacity: 1, callback: options.callback });
};

$.fn.ClearTypeFadeOut = function(options) {
if (options)
$(this)
.css({ opacity: 1 })
.ClearTypeFadeTo({ speed: options.speed, opacity: 0, callback: options.callback });
};
})(jQuery);

关于JQuery 切换函数在 IE 中呈现奇怪的文本(丢失 ClearType?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/457929/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com