id锚点定位并加上偏移量的

付费节点推荐


免费节点


节点使用教程


通常锚点定位我们用通常锚点定位我们用
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上加减适当的数目即可。

未经允许不得转载:Bcoder资源网 » id锚点定位并加上偏移量的

相关推荐

更多优质资源关注微信公众号: bcoder

bcoder
赞 (0)
分享到:更多 ()

评论 0

评论前必须登录!

登陆 注册