图片时钟

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
ul li{
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>
原文地址:https://www.cnblogs.com/HUANGRONG888/p/6075693.html