这个功能很好.它将主体滚动到所需容器的偏移量
function scrolear(destino){
var stop = $(destino).offset().top;
var delay = 1000;
$('body').animate({scrollTop: stop}, delay);
return false;
}
Run Code Online (Sandbox Code Playgroud)
但不是在Firefox中.为什么?
-编辑-
要在接受的答案中处理de double触发器,我建议在动画之前停止元素:
$('body,html').stop(true,true).animate({scrollTop: stop}, delay);
Run Code Online (Sandbox Code Playgroud)