我將平滑滾動添加到我的單頁自由網站。 每當滾動到頁面它顯示了從公元前修復頂部導航欄部分的頂部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>