这个功能很好.它将主体滚动到所需容器的偏移量
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) 我使用bootstrap模式插件.但是模态对话框没有显示在中心.为什么?我的错?
http://dl.dropbox.com/u/573972/stackoverflow/bootstrap/modal.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>test</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS-->
<link rel="stylesheet" href="bootstrap.min.css">
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js'></script>
</head>
<body>
<div id="login" class="modal">
<div class="modal-header">
<h3>Login to Room fuga</h3>
</div>
<div class="modal-body">
hogehoge
</div>
</div>
<script src="bootstrap.min.js">
</script>
<script>
$('#login').modal();
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)