kga*_*ett 7 navigation jquery header sticky smooth-scrolling
我有一个棒导航和平滑滚动的各种问题.我只是不太了解jQuery来解决问题.我正在使用Chris Coyer的平滑滚动片段:http://css-tricks.com/snippets/jquery/smooth-scrolling/.我的页面在这里:http://clients.ekcetera.com/agivingchance.
这是我的问题:
有什么建议?
提前致谢!
1.使用Devin Sturgeon关于平滑滚动帖子的评论中的代码。另外,我添加了一些减法来弥补您的粘性标题。调整到喜欢的程度。
// your functions go here
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 181
}, 1000);
return false;
}
}
});
Run Code Online (Sandbox Code Playgroud)
2.将所有锚点移动到您想要滚动到的实际元素。
(参考:http://css-tricks.com/snippets/jquery/smooth-scrolling/#comment-197181)