我将平滑滚动添加到我的单页自由网站。 每当滚动到页面它显示了从公元前修复顶部导航栏部分的顶部60像素的滚动看起来像这样,当它向下滚动在平滑滚动上添加边距
当我想它推60px下来,向下滚动看起来像这样。
我从公元前W3他们的解决方案似乎是最简单的拉滚动码。刚开始使用jQuery更多,所以任何帮助将不胜感激。 下面的代码使用:
<script>
$(document).ready(function(){
$(".navbar a, footer a[href='#myPage']").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 1100, function(){
window.location.hash = hash;
});
} // End if
});
})
</script>