1
我使用下面的代碼來平滑鏈接之間的滾動,並且它完美地工作。手機上的不同滾動偏移量
我目前的偏移量爲93px,但希望使其更小,如果不能在小設備上移除。我想知道是否可以更改較小分辨率的偏移值。誰能幫忙?
var jump=function(e)
{
if (e){
e.preventDefault();
var target = $(this).attr("href");
}else{
var target = location.hash;
}
$('html,body').animate(
{
scrollTop: $(target).offset().top-93
},2000,function()
{
location.hash = target;
});
}
$('html, body').hide();
$(document).ready(function()
{
$('a[href^=#]').bind("click", jump);
if (location.hash){
setTimeout(function(){
$('html, body').scrollTop(0).show();
jump();
}, 0);
}else{
$('html, body').show();
}
});