-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
60 lines (49 loc) · 1.82 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Analog Watch</title>
<link rel="stylesheet" href="analog.css">
</head>
<body>
<div class="container">
<div class="clock">
<div id="hour" style="--clr:cyan; --h:74px" class="hand"><i></i></div>
<div id="min" style="--clr:gold; --h:84px" class="hand"><i></i></div>
<div id="sec" style="--clr:rgb(236, 10, 10); --h:94px" class="hand"><i></i></div>
<span style="--i:1;"><b>1</b></span>
<span style="--i:2;"><b>2</b></span>
<span style="--i:3;"><b>3</b></span>
<span style="--i:4;"><b>4</b></span>
<span style="--i:5;"><b>5</b></span>
<span style="--i:6;"><b>6</b></span>
<span style="--i:7;"><b>7</b></span>
<span style="--i:8;"><b>8</b></span>
<span style="--i:9;"><b>9</b></span>
<span style="--i:10;"><b>10</b></span>
<span style="--i:11;"><b>11</b></span>
<span style="--i:12;"><b>12</b></span>
</div>
</div>
<script>
let hr = document.getElementById('hour');
let min = document.getElementById('min');
let sec = document.getElementById('sec');
function displayTime(){
let date = new Date();
// getting hour ,min,sec from date
let hh = date.getHours();
let mm = date.getMinutes();
let ss = date.getSeconds() ;
let hRotation = 30*hh + mm/2;
let mRotation = 6*mm;
let sRotation = 6*ss
hr.style.transform = `rotate(${hRotation}deg)`;
min.style.transform = `rotate(${mRotation}deg)`;
sec.style.transform = `rotate(${sRotation}deg)`;
}
setInterval(displayTime, 1000);
</script>
</body>
</html>