图片时钟

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
ul li{
width:24px;
height:35px;
overflow: hidden;
float: left;
font-size: 30px;
position: relative;
}
ul li img{
position: absolute;
top:0;
left:0;
}
</style>
<script src="move1.js"></script>
<script>
function addZero(n){
return n<10 ? '0'+n : ''+n;
}
window.onload=function(){
var aImg=document.getElementsByTagName('img');
function clock(){
var oDate=new Date();
var oHour=oDate.getHours();
var oMin=oDate.getMinutes();
var oSec=oDate.getSeconds();
var str=addZero(oHour)+addZero(oMin)+addZero(oSec);
for(var i=0;i<aImg.length;i++){
move(aImg[i],{top:-str.charAt(i)*35})
}
}
clock();
setInterval(clock,1000);
}
</script>
</head>
<body>
<ul>
<li><img src="img/num.png" alt=""/></li>
<li><img src="img/num.png" alt=""/></li>
<li>:</li>
<li><img src="img/num.png" alt=""/></li>
<li><img src="img/num.png" alt=""/></li>
<li>:</li>
<li><img src="img/num.png" alt=""/></li>
<li><img src="img/num.png" alt=""/></li>
</ul>
</body>
</html>
posted @ 2016-11-17 21:59  HuangRong  阅读(137)  评论(0编辑  收藏  举报