-
Notifications
You must be signed in to change notification settings - Fork 354
Expand file tree
/
Copy pathindex.html
More file actions
37 lines (32 loc) · 1.25 KB
/
index.html
File metadata and controls
37 lines (32 loc) · 1.25 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>day4</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="clock">
<div class="centerPoint"></div>
<div class="hourHand"></div>
<div class="minuteHand"></div>
<div class="secondHand"></div>
</div>
<script>
function runClock() {
let currentTime = new Date();
let secondRotate = (currentTime.getSeconds() / 60) * 360;
let minuteRotate = (currentTime.getMinutes() / 60) * 360;
let hourRotate = ((currentTime.getHours() + (currentTime.getMinutes() / 60)) / 12) * 360;
let secondHand = document.querySelector(".secondHand");
let minuteHand = document.querySelector(".minuteHand");
let hourHand = document.querySelector(".hourHand");
secondHand.style.transform = `rotate(${secondRotate}deg) translateY(-30%)`;
minuteHand.style.transform = `rotate(${minuteRotate}deg) translateY(-50%)`;
hourHand.style.transform = `rotate(${hourRotate}deg) translateY(-50%)`;
}
setInterval(runClock, 1000);
</script>
</body>
</html>