console
var box = document.querySelector('.container ul'),
items = document.querySelectorAll('li'),
itemH = items[0].offsetHeight,
boxH = box.offsetHeight,
lengths = items.length,
time = 1500,
step = 2;
for(var i=0; i<step; i++) {
var node = items[i].cloneNode(true);
box.appendChild(node);
}
function run() {
setTimeout(function() {
var mt = parseInt(box.style.marginTop || 0);
mt -= itemH * step
box.style.transition = 'margin .5s';
if(Math.abs(mt) >= boxH + itemH * step) {
box.style.transition = 'initial';
mt = 0
}
box.style.marginTop = mt + 'px';
run();
},time)
}
run()
<div class="container">
<ul>
<li>1大促销...</li>
<li>2大促销...</li>
<li>3大促销...</li>
<li>4大促销...</li>
<li>5大促销...</li>
<li>6大促销...</li>
<li>7大促销...</li>
<li>8大促销...</li>
</ul>
</div>
*{padding:0;margin: 0;}
.container{
margin:100px auto;
width: 100px;
height: 40px;
overflow:hidden;
border:1px solid #ccc;
}
li{
list-style:none;
height:20px;
line-height:20px;
text-align:center;
}