Smooth Scroll JQuery在Chrome中无法顺利运行?

时间:2013-07-18 15:03:17

标签: javascript jquery html

我正在使用这个JQuery脚本来实现垂直平滑滚动效果。它在Internet Explorer和Firefox中完美运行但在Google Chrome的最新版本中根本不是很流畅???怎么会?我应该更改脚本中的某些内容,还是有另一个平滑的滚动脚本在所有浏览器中都能很好地运行?

在谷歌浏览器中,平滑的滚动效果实际上会在短暂的时间内摇晃并停止,这样看起来有点难看。

这是JavaScript / JQuery代码:

(function() {
    $('header ul a').bind('click',function(event){
        var $anchor = $(this);

        $('html, body').animate({
            scrollTop: $($anchor.attr('href')).offset().top + "px"
        }, 1500);
        /*
        if you don't want to use the easing effects:
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1000);
        */
        event.preventDefault();
    });
});

我的HTML有5 <section>个,每个部分都有自己的ID(主页,关于,服务,图库和联系人),所以这里没什么了不起的。谢谢你的帮助!

0 个答案:

没有答案
相关问题