滚动条和平滑滚动代码

问题描述 投票:0回答:1

请查看此页面(例如)

http://www.christinamichael.in/create-a-powerful-human-disintegration-effect-in-photoshop

我想知道我怎样才能拥有这样的东西?

我希望 firefox 和 chrome 支持一些东西。

javascript jquery html css scroll
1个回答
1
投票

您可以使用ANCHOR标签进行平滑滚动。 以下结果。


$(函数() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'') && location.hostname == this.hostname) { var target = $(this.hash); 目标=目标.长度?目标:$('[name=' + this.hash.slice(1) +']'); if (目标.长度) { $('html,body').animate({ 滚动顶部:target.offset().top }, 1000); 返回假; } } }); });

© www.soinside.com 2019 - 2024. All rights reserved.