JSFiddle - React, Tailwind, and code Playground
by T_Recks
HTML
<div>
<ul>
<li>Item #1</li>
<li>Item #2</li>
<li>Item #3</li>
<li>Item #4</li>
<li>Item #5</li>
<li>Item #6</li>
</ul>
</div>
CSS
div { width:500px;overflow:hidden; }
ul { list-style-type:none;width:5000px;margin:0;padding:0; }
li { height:100px;width:200px;float:left;text-align:center;margin:0;padding:0; }
li:first-child {
margin-left: -200px;
}
.even {background: #fff}
.odd {background: #000;color:#fff;}
JavaScript
$('ul li:even').addClass('even');
$('ul li:odd').addClass('odd');
// reverse items
var list = $('ul');
var listItems = list.children('li');
list.append(listItems.get().reverse());
// rearrange last two items so first slide starts on left
list.prepend($('ul li:last-child').prev('li').andSelf());
function spinCarousel() {
$("ul li:first-child").animate({ marginLeft: 0 }, 3000, 'linear', function () {
$("ul li:last-child").prependTo('ul').css('margin-Left', -200);
spinCarousel();
});
}
spinCarousel();