-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
105 lines (102 loc) · 2.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>clock</title>
<style>
*{
padding: 0;
margin: 0;
}
ul{
list-style: none;
}
#clock{
height: 200px;
width: 200px;
border: 1px solid;
border-radius: 50%;
margin: 100px auto;
position: relative;
}
#dial li{
height: 4px;
width: 2px;
position: absolute;
background: #000000;
left: 99px;
top:0;
-webkit-transform-origin: center 100px;
-moz-transform-origin:center 100px;
-o-transform-origin:center 100px;
-ms-transform-origin:center 100px;
transform-origin:center 100px;
}
#dial li:nth-child(5n+1){
height: 8px;
}
#hour,#minute,#second{
-webkit-transform-origin: center bottom;
-moz-transform-origin:center bottom;
-o-transform-origin:center bottom;
-ms-transform-origin:center bottom;
transform-origin:center bottom;
}
#hour{
height: 35px;
width: 6px;
background: #000000;
position: absolute;
left: 97px;
top:65px;
}
#minute{
height: 45px;
width: 4px;
background: #999999;
position: absolute;
left: 98px;
top:55px;
}
#second{
height: 65px;
width: 2px;
background: #f00;
position: absolute;
left: 99px;
top: 35px;
}
</style>
</head>
<body>
<div id="clock">
<ul id="dial">
</ul>
<div id="hour"></div>
<div id="minute"></div>
<div id="second"></div>
</div>
<script>
var oDial = document.getElementById('dial');
var oHour = document.getElementById('hour');
var oMinute = document.getElementById('minute');
var oSecond = document.getElementById('second');
var html = "";
for(var i=0;i<60;i++){
html += "<li style='-webkit-transform:rotate("+i*6+"deg)'></li>";
}
oDial.innerHTML = html;
function run() {
var date = new Date();
var second = date.getSeconds(),
minute = date.getMinutes() + second/60,
hour = date.getHours() + minute/60;
oHour.style.WebkitTransform = "rotate("+hour*30+"deg)";
oMinute.style.WebkitTransform = "rotate("+minute*6+"deg)";
oSecond.style.WebkitTransform = "rotate("+second*6+"deg)";
}
run();
setInterval(run,1000);
</script>
</body>
</html>