我创建了一个仪表板,它会回显所有行,但我想要一个自动滚动,它会慢慢地向下滚动到页面底部,然后慢慢地滚动回顶部并重复。我已经用谷歌搜索了这个,但无法获得有效的代码。我一直在寻找 jQuery 代码,但任何东西都可以。
因为页面会一直调整,所以不能有固定高度的滚动。
不确定您是否需要更多信息,但如果需要,我会更新这个问题。
问候
策略
你可以使用这样的东西。
//run instantly and then goes after (setTimeout interval)
$("html, body").animate({ scrollTop: $(document).height() }, 4000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 4000);
},4000);
var scrolltopbottom = setInterval(function(){
// 4000 - it will take 4 secound in total from the top of the page to the bottom
$("html, body").animate({ scrollTop: $(document).height() }, 4000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 4000);
},4000);
},8000);
//Use this to stop the scroller -> clearInterval(scrolltopbottom);
例子:http://jsfiddle.net/NaP8D/11/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)