我有下面的滾動腳本,它滾動頁面的罰款,我的工作方式也是如此。JQuery從瀏覽器頂部滾動到偏移量?
$(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;
}
}
});
});
不過,我需要它忽略上面說200像素,因爲我在頁面頂部的內容滾動背後有一個固定的頭。
這意味着當我滾動到頂部它將內容滾動到固定標題後面,所以我不能看到它,所以我需要它滾動到正下方的標題..所以要將標題的底部作爲頂部瀏覽器我想....
這可以做,因爲它會很方便嗎?
非常感謝所有幫助
謝謝你問這個問題一直掙扎了一夜想了解如何完全相同的原因完成此操作! – Robert 2016-11-26 08:43:37