通过jQuery的aminate动画方法定位。
示例如下:
scrollOffset($("#qa").offset());
// jQuery 定位让body的scrollTop等于pos的top,就实现了滚动
function scrollOffset(scroll_offset) {
$("body,html").animate({
scrollTop: scroll_offset.top - 70
}, 0);
}
通过jQuery的aminate动画方法定位。
示例如下:
scrollOffset($("#qa").offset());
// jQuery 定位让body的scrollTop等于pos的top,就实现了滚动
function scrollOffset(scroll_offset) {
$("body,html").animate({
scrollTop: scroll_offset.top - 70
}, 0);
}
转载于:https://my.oschina.net/infowangxin/blog/671562