-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2017_9_3.html
121 lines (120 loc) · 3.19 KB
/
2017_9_3.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
120
121
<<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
*{
margin: 0;
padding: 0;
}
li{
list-style: none;
}
#clock{
width: 200px;
height: 200px;
border: 1px solid #000;
border-radius: 50%;
margin: 200px auto;
position:relative;
}
#dail li{
width: 2px;
height: 6px;
background: #000;
position: absolute;
top :0px;
left: 100px;
transform-origin: 0 100px;
}
#dail li :nth-child(5n+1){/*第六个child*/
height:10px;
}
#hour{
width: 4px;
height: 40px;
background: #000;
position: absolute;
left: 98px;
top: 60px;
}
#minute{
width: 2px;
height: 70px;
background: #999;
position: absolute;
left: 99px;
top: 30px;
}
#second{
width: 2px;
height: 70px;
background: #f00;
position: absolute;
left: 99px;
top: 30px;
}
#clock div{
transform-origin: bottom;
}
#dial li:nth-child(1){
transform: rotate(0deg);
}
#dial li:nth-child(2){
transform: rotate(6deg);
}
#dial li:nth-child(3){
transform: rotate(12deg);
}
#dial li:nth-child(4){
transform: rotate(18deg);
}
#dial li:nth-child(5){
transform: rotate(24deg);
}
#dial li:nth-child(6){
transform: rotate(30deg);
}
</style>
<title>钟表</title>
</head>
<body>
<div id="clock">
<ul id="dail">
<!-- <li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li> -->
</ul>
<div id="hour"></div>
<div id="minute"></div>
<div id="second"></div>
</div>
<script>
var oDail=document.getElementById("dail");
var oHour=document.getElementById("hour");
var oMinute=document.getElementById("minute");
var oSecond=document.getElementById("second");
var lis = "";
for(var i=0;i<60;i++){
// var oLi=document.createElement("li");
// oDail.appendChild(oLi);
lis+="<li style='transform:rotate("+i*6+"deg);'></li>";
}
oDail.innerHTML = lis;
function run(){
var now =new Date();
var second = now.getSeconds();
var minute = now.getMinutes()+second/60;
var hour = now.getHours()+minute/60;
oHour.style.transform = "rotate("+ (hour * 30 + minute / 60 * 30) +"deg)";
oMinute.style.transform = "rotate("+ minute * 6 +"deg)";
oSecond.style.transform = "rotate("+ second * 6 +"deg)";
}
</script>
</body>
</html>