通常锚点定位我们用通常锚点定位我们用
location.href = “#elementid”;
但当有固定的header时,有可呢会被header覆盖。
解决方法:
页面将滑动至指定元素id处
$(“a”).click(function(){
var index = $(“a”).index(this);
$(“html,body”).animate({scrollTop:$(“#elementid” + index).offset().top-105},200)
return false;
});
200为速度
在offset.top上加减适当的数目即可。