0
我正在使用平滑滾動片段。我有一個固定的標題,並希望錨節停在我的標題下。我如何編輯這段代碼讓它們停止在頁面頂部以下大約100像素?平滑滾動到錨點編輯頁面頂部
$(document).ready(function(){
$('a[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) {
var targetOffset = $target.offset(). top;
$('html,body')
.animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
});
我只是需要在頁面頂部以下停止100px的部分。我對jquery非常陌生,所以請在我缺乏知識的情況下發表看法。由於
謝謝:)艾哈邁德添加「+ 100」移動「頂」了,所以我做' - 100',這完美的工作:)再次感謝你。 –
不客氣@MattDelahoussaye,但不要忘了投票,並接受以及如果它確實可以接受:) –
我對這個網站很新,所以我仍然在學習禮儀:)投票和接受!謝謝 –