最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

無縫滾動js代碼通俗易懂(自寫)

 更新時間:2013年06月19日 17:40:13   作者:  
本人閑暇時自寫的無縫滾動js,代碼簡單實(shí)用,通俗易懂,曬出來與大家共享,感興趣的朋友可以參考下哈
復(fù)制代碼 代碼如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標(biāo)題文檔</title>
<style>
*{padding:0; margin:0;}
ul{ list-style:none;}
#div{ width:300px; height:100px; margin:100px auto; border:1px solid #ff0000; position:relative; overflow:hidden;}
#div ul{ position:absolute; height:100px; left:0;}
#div ul li{ width:300px; height:100px; line-height:100px; text-align:center; float:left}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById("div");
var oUl=oDiv.getElementsByTagName("ul")[0];
var oLi=oUl.getElementsByTagName("li");
var oInput=document.getElementsByTagName('input');
oUl.innerHTML +=oUl.innerHTML;
oUl.style.width=oLi[0].offsetWidth*oLi.length+"px";
var iSeep=-2;
var tamer=null;
clearInterval(tamer);
function starMove(){
tamer=setInterval(function(){
oUl.style.left=oUl.offsetLeft+iSeep+"px";
if(-oUl.offsetLeft >= oUl.offsetWidth/2){
oUl.style.left="0px";
}else if(oUl.offsetLeft>0){
oUl.style.left=-oUl.offsetWidth/2+"px";
}
},30)
}
starMove();
oDiv.onmouseover=function(){
clearInterval(tamer);
}
oDiv.onmouseout=function(){
starMove();
}
oInput[0].onclick=function(){
iSeep=-2;
}
oInput[1].onclick=function(){
iSeep=2;
}
}
</script>
</head>
<body>
<input type="button" value="左">
<input type="button" value="右">
<div id='div'>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</body>
</html>

相關(guān)文章

最新評論

颍上县| 偃师市| 乐都县| 增城市| 建始县| 沧州市| 教育| 临湘市| 新泰市| 衡水市| 阿拉尔市| 敦煌市| 义马市| 福泉市| 望城县| 上饶县| 安宁市| 冷水江市| 丽水市| 靖远县| 金山区| 吴旗县| 榆林市| 嘉禾县| 平凉市| 综艺| 岳西县| 双鸭山市| 嵊泗县| 逊克县| 石嘴山市| 辽源市| 康定县| 清镇市| 徐州市| 贵南县| 上虞市| 湘乡市| 通州区| 新兴县| 日喀则市|