0
我使用这个代码smoothscroll目标链接偏移值,但我不能设置偏移值top
到100px
:无法设置smoothscroll的jQuery
$(function() {
$('a[href*=#]:not([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) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
哦,伙计我刚刚弄明白了我自己。 –