<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<style type="text/css">
body,div,dl,dd,dt,a,img{ margin:0px; padding:0px;}
img{ border:0 none; vertical-align:top;}
a{ font-size:12px; color:#000; text-decoration:none;}
.main_M_pro{ width:520px; height:auto; margin-top:24px; overflow:hidden; margin:24px auto 0px;}
.main_M_proDl{ width:1000%; overflow:hidden;}
.main_M_pro dl{ float:left; width:133px; height:171px; margin-left: 3px;margin-right: 30px;}
.main_M_pro dt{ width:125px; height:125px; border:#d4d3d3 1px solid;}
.main_M_pro dd{ width:100%; height:44px; line-height:44px; overflow:hidden; text-align:center;}
</style>
<div class="main_M_pro">
<div class="main_M_proDl" id="box">
<dl>
<dt><a href="../product.html"><img src="http://www.baidu.com/img/bdlogo.png" width="125" height="125" alt="1" /></a></dt>
<dd><a href="../product.html">FDK、FSK系列逆变变压器</a></dd>
</dl>
<dl>
<dt><a href="../product.html"><img src="http://picture.youth.cn/qtdb/201508/W020150804262070298525.jpg" width="125" height="125" alt="2" /></a></dt>
<dd><a href="../product.html">FDK、FSK系列逆变变压器</a></dd>
</dl>
<dl>
<dt><a href="../product.html"><img src="http://d.youth.cn/qwtf2015/tpy/bjtj/201506/W020150710545179254939.jpg" width="125" height="125" alt="3" /></a></dt>
<dd><a href="../product.html">FDK、FSK系列逆变变压器</a></dd>
</dl>
<dl>
<dt><a href="../product.html"><img src="http://d.youth.cn/qwtf2015/tpy/bjtj/201506/W020150609346286302954.jpg" width="125" height="125" alt="3" /></a></dt>
<dd><a href="../product.html">FDK、FSK系列逆变变压器</a></dd>
</dl>
</div>
</div>
</body>
<script>
var boxObj=document.getElementById("box");
var dlObj=boxObj.getElementsByTagName("dl");
var stop;
function fun(num)
{
num+=2;
dlObj[0].style.marginLeft=(3-num)+"px";
if(num<=166)//第一个dl移动的最大距离,即盒子的宽度
{
stop=window.setTimeout(function(){fun(num);},50);
}
else
{
boxObj.appendChild(dlObj[0]);//将第一个dl插到最后
dlObj[dlObj.length-1].style.marginLeft=3+"px";//将移到最后的dl的marginLeft值设置为初始值
fun(0)
}
}
fun(0);//一般设置起始值为0
boxObj.onmouseenter=function()
{
window.clearTimeout(stop);
};
boxObj.onmouseleave=function()
{
var num=3-parseInt(dlObj[0].style.marginLeft);//将之前停止时的num值得到
fun(num);
}
</script>
</html>
转载于:https://my.oschina.net/u/2421889/blog/487394