JQuery
$('.scroller').each(function(){ $(this).find('img').clone().appendTo($(this)); }); (function move(){ $('.scroller').scrollLeft(0).stop().animate({scrollLeft:310},800,'linear',move); })();
HTML:
<div class="scroller"> <img src="" alt="" /> </div>
CSS
.scroller{ width:310px; height:80px; white-space:nowrap; word-spacing:-1em; overflow:hidden; margin:30px; } .scroller img{ display:inline; }
He will make clones only once. Than my jQuery script will create a loop that will just play with the scrollLeft() element property.
NB: this is just a simple example, you can do 310px dynamic calculation, but this is another story, let it simplify it.
Roko C. Buljan
source share