CSS备选:
另外,您可以在此CodePen使用CSS转换,如: https://codepen.io/jamesbarnett/pen/kfmKa
更先进:
$(document).ready(function(){
var scroller = $('#scroller'); // scroller $(Element)
var scrollerWidth = scroller.width(); // get its width
var scrollerXPos = window.innerWidth; // init position from window width
var speed = 1.5;
scroller.css('left', scrollerXPos); // set initial position
function moveLeft() {
\t if(scrollerXPos <= 0 - scrollerWidth) scrollerXPos = window.innerWidth;
\t scrollerXPos -= speed;
scroller.css('left', scrollerXPos);
window.requestAnimationFrame(moveLeft);
}
\t \t window.requestAnimationFrame(moveLeft);
});
.scroll {
display: block;
position: absolute;
overflow: visible;
white-space: nowrap;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="scroller" class="scroll">This text be scrollin'!</div>
肮脏的解决方案(我原来的答复):
文本运行到左边没有人停下:
在这个例子中,这将是速战速决。在这里你会告诉文本总是从那个位置开始。 (时间已经跑起来之后 - 这意味着不一定只是当它已经离开了屏幕)
$(document).ready(function(){
function scroll() {
$('.scroll').css('right', '-200px').animate({
right: $(document).width()
}, 8000, scroll);
}
scroll();
});
我想尝试使用jquery动画来做选取框 – Coolguy