【发布时间】:2011-03-03 19:52:08
【问题描述】:
我在 jQuery 中使用 scrollTop 函数导航到顶部,但奇怪的是,在我进行一些更改后,“平滑动画滚动”在 Safari 和 Chrome 中停止工作(滚动没有平滑动画)。
但它在 Firefox 中仍然可以顺利运行。有什么问题?
这是我使用的jQuery函数,
jQuery:
$('a#gotop').click(function() {
$("html").animate({ scrollTop: 0 }, "slow");
//alert('Animation complete.');
//return false;
});
HTML
<a id="gotop" href="#">Go Top </a>
CSS
#gotop {
cursor: pointer;
position: relative;
float: right;
right: 20px;
/*top:0px;*/
}
【问题讨论】:
-
jsbin.com/erade/2 在 chrome 上运行良好
-
@jAndy,我想知道为什么
scrollTop,它不是一个有效的 css 属性,在你的演示中工作?...你能分享一些关于它的信息或链接吗? -
@Reigel:我不得不承认,我不能。我使用它很像一个黑盒,但 jQuery 实际上将它标准化为跨浏览器。
-
@jAndy - 好的...但我想在动画 css 地图属性中使用
scrollTop是不可取的...不过我仍在挖掘..
标签: jquery jquery-ui jquery-selectors