我想在用戶向下滾動頁面時將div滑動到我的頁面上(div將包含一個鏈接,將它們帶回頁面的頂部) 。這是我目前使用的代碼:jQuery讓div滑入滾動頁面
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > 100) {
jQuery('.totop').animate({ right: '0px' });
} else {
jQuery('.totop').animate({ right: '-300px' });
}
});
而CSS:
.totop {
position:fixed;
bottom:50%;
right:-300px;
width:300px;
height:100px;
font-size:30px;
color:white;
background:#f18500;
}
股利的行爲非常奇怪的是,當我向下滾動的div大約需要5秒鐘出現,那麼它進入視野,但看起來好像它正在幾次嘗試再次滑落,然後仍然保持靜止,當我滑回頂部時消失......但在大約5秒後再次。希望能幫助我找出我的代碼有什麼問題。
檢查這篇文章創建一個頁面頂部的滾動︰http://recentsolutions.net/web-development/smooth-scroll/ – 2013-02-22 14:37:59