我一直在用 Firefox 和 IE 8 开发我的网站。主页上有一个图像悬停效果(以及摄影和绘图部分)。您可以在http://www.dgendill.com的源代码中查看代码。在 Firefox 中,效果完美。在 IE 8 中,它可以工作,但速度要慢得多。这是我尝试提高速度的方法:
- 使用优化的 jQuery 库
缩小了 jQuery 遍历 DOM 的范围。例如:
$(".sectionLink","#divLandingPage").hover( function(){ $(this).addClass("hover"); $(this).fadeTo(100,.8); }, function(){ $(this).removeClass("hover"); $(this).fadeTo(100,.99); } );
我试过改变图像的显示类型。显示块、内联块和内联。
任何想法为什么 IE 8 这么慢?我的 HTML 是有效的 4.01。
这是一个遇到同样问题的人:http: //mdasblog.wordpress.com/2009/07/24/jquery-fun-with-animation-and-opacity/
我决定只禁用 IE 中的悬停效果。
if(jQuery.support.opacity) {
$(".sectionLink","#divLandingPage").hover(
function(){
$(this).addClass("hover");
$(this).fadeTo(100,.8);
},
function(){
$(this).removeClass("hover");
$(this).fadeTo(100,.99);
}
);
}