<html>
<head>
<style type="text/css">
*{margin:0 0;padding:0 0}
#wrap {
left:100px;
background: #FFF;
border: 1px dashed #CCC;
}
</style></head>
<body>
<div id="wrap" style="position:absolute;overflow-x: hidden;white-space:nowrap;width: 475px;height:40px">
<div id="demo" style="position:relative">
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
</div>
</div>
<script>
/*
var speed=10; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab. {clearInterval(MyMar)};
tab. {MyMar=setInterval(Marquee,speed)};
*/
(function(){
var left = 0;
run(new Object, 1000);
function run(oDiv,iTime){
var demo = document.getElementById("demo");
var iWidth = demo.getElementsByTagName("a")[0].offsetWidth;
function move(obj, iTarget){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
left--;
if(iTarget >= left){
left = 0;
obj.style.left = "0px";
}else{
obj.style.left = left % 96 + "px";
}
obj. {clearInterval(obj.timer)};
obj. {move(demo, -96);};
},30)
}
autoPlay();
function autoPlay(){
move(demo, -96);
}
}
})()
</script></body></html>
转载于:https://blog.51cto.com/tomastong/1716732