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,但不要忘了投票,并接受以及如果它确实可以接受:) –
我对这个网站很新,所以我仍然在学习礼仪:)投票和接受!谢谢 –