-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.html
80 lines (74 loc) · 2.27 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
<html>
<head>
<style>
.clock-box{
display: flex;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
}
.clock{
position: relative;
border: 15px rgba(24, 144, 243, 0.37) solid;
border-radius: 50%;
height: 180px;
width: 180px;
}
.sec-hand{
position: absolute;
border: 1px rgba(240, 146, 5, 1) solid;
width: 50%;
transform-origin: 100%;
transform: rotate(90deg);
margin-top: 90px;
}
.min-hand{
position: absolute;
border: 1px rgba(240, 146, 5, 1) solid;
width: 50%;
margin-top: 90px;
transform: rotate(90deg);
transform-origin: 100%;
}
.hour-hand{
position: absolute;
border: 1px rgba(240, 146, 5, 1) solid;
width: 50%;
margin-top: 90px;
transform: rotate(90deg);
transform-origin: 100%;
}
</style>
<title>
clock
</title>
</head>
<body>
<div class="clock-box">
<div class="clock">
<div class="sec-hand"></div>
<div class="min-hand"></div>
<div class="hour-hand"></div>
</div>
</div>
</body>
<script>
var secondhand=document.querySelector('.sec-hand');
var minutehand=document.querySelector('.min-hand');
var hourhand=document.querySelector('.hour-hand');
function setdate(){
var now=new Date();
var seconds=now.getSeconds();
var secondsdeg=(seconds*6)+90;
secondhand.style.transform="rotate("+secondsdeg+"deg)";
var minutes=now.getMinutes();
var minsdeg=(minutes*6)+90;
minutehand.style.transform="rotate("+minsdeg+"deg)";
var hours=now.getHours();
var hoursdeg=(hours*30)+(minutes/2)+90;
hourhand.style.transform="rotate("+hoursdeg+"deg)";
}
setInterval(setdate,1000);
</script>
</html>