-
Notifications
You must be signed in to change notification settings - Fork 0
/
01 - 钟表.html
115 lines (107 loc) · 2.7 KB
/
01 - 钟表.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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>钟表</title>
<style type="text/css">
.box{
margin:0px auto;
width: 500px;
height: 500px;
border: 10px solid lightgray;
border-radius: 50%;
position: relative;
}
.box div{
width: 10px;
height: 10px;
text-align: center;
line-height: 30px;
font-size: 30px;
position: absolute;
left: 50%;
top: 50%;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
border: 1px solid red;
margin: -15px 0 0 -15px;
}
.box #hour{
width: 15px;
height: 80px;
background-color: black;
border-radius: 15px;
transform-origin: bottom;
top: 190px;
}
.box #minute{
width: 13px;
height: 120px;
background-color: pink;
border-radius: 10px;
transform-origin: bottom;
top: 150px;
}
.box #second{
width: 8px;
height: 160px;
border-radius: 5px;
background-color: green;
transform-origin: bottom;
top: 110px;
}
</style>
</head>
<body>
<div class="box">
<div class="div">1</div>
<div class="div">2</div>
<div class="div">3</div>
<div class="div">4</div>
<div class="div">5</div>
<div class="div">6</div>
<div class="div">7</div>
<div class="div">8</div>
<div class="div">9</div>
<div class="div">10</div>
<div class="div">11</div>
<div class="div">12</div>
<div class="div">13</div>
<div class="div">14</div>
<div class="div">15</div>
<div class="div">16</div>
<div class="div">17</div>
<div class="div">18</div>
<div class="div">19</div>
<div class="div">20</div>
<div class="div">21</div>
<div class="div">22</div>
<div class="div">23</div>
<div class="div">0</div>
<!-- <div id="hour"></div>
<div id="minute"></div>
<div id="second"></div> -->
</div>
</body>
<script type="text/javascript">
var nums = document.getElementsByClassName("div");
for(var i = 0; i < nums.length; i++){
nums[i].style.transform = "rotate("+ ((i+1) * 30)+"deg) translateY(-220px) rotate("+((i+1) * -30)+"deg)";
nums[i].style.transform = "rotate("+ ((i+1) * 15)+"deg) translateY(-220px) ";
}
// var hour = document.getElementById('hour');
// var minute = document.getElementById('minute');
// var second = document.getElementById('second');
// setInterval(function(){
// var date=new Date();
// // console.log(date)
// var s =date.getSeconds();
// var m =date.getMinutes();
// var h =date.getHours();
// // console.log(h);
// second.style.transform="rotate(" + (s*6) +"deg)";
// minute.style.transform="rotate(" + (m*6) +"deg)";
// hour.style.transform="rotate(" + (h*30) +"deg)";
// },1000);
</script>
</html>