【发布时间】:2014-01-06 23:56:32
【问题描述】:
我正在尝试为我的 HTML 页面设置动画,以便它滚动到一个标签,所以我使用了这段代码
$(document).ready(function(){
$('#button a').click(function( e ){
e.preventDefault();
var el = $( this.getAttribute('href') );
var offs = el.offset();
$('html, body').stop().animate({ scrollTop: offs.top-100 },500);
});
});
HTML
<p id="button"><a href="#moreInfo">More Info</a></p>
<!--Some other elemts here-->
<div id="moreInfo" style="text-align: center">
它实际上会滚动到所需的位置,但它不做动画,它只会滚动而没有任何应有的酷过渡。
提前致谢。
【问题讨论】:
-
你期待哪种“酷过渡”?
-
应该做的,所有的身体向下移动,到div。
标签: jquery html animation jquery-animate