-
Notifications
You must be signed in to change notification settings - Fork 34
/
clock.html
119 lines (107 loc) · 3.26 KB
/
clock.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!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>
<style type="text/css">
#box1 {
width: 200px;
height: 200px;
border: 2px #000 solid;
margin: 100px auto 0;
padding: 0;
border-radius: 50%;
position: relative;
overflow: hidden;
}
#box1 ul {
height: 200px;
padding: 0;
margin: 0;
position: relative;
list-style: none;
background: url(img/9.jpg) -110px no-repeat;
}
#hour, #min, #sec {
position: absolute;
background: #000;
-webkit-transform-origin: bottom;
}
#box1 ul li {
width: 2px;
height: 6px;
background: #000;
position: absolute;
left: 99px;
top: 0;
-webkit-transform-origin: 0 100px;
z-index: 3;
}
#box1 li:nth-of-type(5n+1) {
height: 10px;
background: #000;
}
#hour {
width: 6px;
height: 50px;
bottom: 100px;
left: 97px;
}
#min {
width: 4px;
height: 70px;
bottom: 100px;
left: 98px;
}
#sec {
width: 2px;
height: 90px;
bottom: 100px;
left: 99px;
}
</style>
</head>
<script>
window.onload = function () {
var oBox = document.getElementById('box1');
var oUl = oBox.getElementsByTagName('ul')[0];
var oHour = document.getElementById('hour');
var oMin = document.getElementById('min');
var oSec = document.getElementById('sec');
newTime(oHour, oMin, oSec);
setInterval(function () {
newTime(oHour, oMin, oSec);
}, 1000);
function newTime(oHour, oMin, oSec) {
/*var oDate=new Date();
var iSec=oDate.getSeconds();
var iMin=oDate.getMinutes()+iSec/60;
var iHour=(oDate.getHours()%12)+iMin/60;
oSec.style.WebkitTransform="rotate("+iSec*6+"deg)";
oMin.style.WebkitTransiform="rotate("+iMin*6+"deg)";
oHour.style.WebkitTransform="rotate("+iHour*30+"deg)";
*/
var oDate = new Date();
var iSec = oDate.getSeconds();
var iMin = oDate.getMinutes() + iSec / 60;
var iHour = (oDate.getHours() % 12) + iMin / 60;
oSec.style.WebkitTransform = "rotate(" + (iSec * 360 / 60) + "deg)";
oMin.style.WebkitTransform = "rotate(" + (iMin * 360 / 60) + "deg)";
oHour.style.WebkitTransform = "rotate(" + (iHour * 360 / 12) + "deg)";
}
for (var i = 0; i < 60; i++) {
oUl.innerHTML += "<li style='-webkit-transform:rotate(" + 6 * i + "deg)'></li>";
}
}
</script>
<body>
<div id="box1">
<ul>
</ul>
<div id="hour"></div>
<div id="min"></div>
<div id="sec"></div>
</div>
</body>
</html>