Skip to content

Commit 83f6f62

Browse files
Merge pull request #48 from Nipunkhattri/main
added a wall-clock project
2 parents b40d831 + 9c50e07 commit 83f6f62

5 files changed

Lines changed: 112 additions & 0 deletions

File tree

wall-clock/.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"liveServer.settings.port": 5501
3+
}

wall-clock/clock.png

4.36 KB
Loading

wall-clock/index.css

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
html {
3+
background-size:cover;
4+
font-family:'helvetica neue';
5+
text-align: center;
6+
font-size: 10px;
7+
}
8+
9+
body {
10+
margin: 0;
11+
font-size: 2rem;
12+
flex:1;
13+
min-height: 100vh;
14+
align-items: center;
15+
}
16+
17+
.clock{
18+
position: relative;
19+
margin: auto;
20+
height: 30vw;
21+
width: 30vw;
22+
background: url(clock.png) no-repeat;
23+
background-size: 100%;
24+
}
25+
26+
#hour,#minute,#second{
27+
position: absolute;
28+
background: black;
29+
border-radius: 10px;
30+
transform-origin: bottom;
31+
}
32+
33+
#hour{
34+
width: 1.8%;
35+
height: 25%;
36+
top: 25%;
37+
left: 48.85%;
38+
opacity: 0.8;
39+
}
40+
#minute{
41+
width: 1.6%;
42+
height: 30%;
43+
top: 19%;
44+
left: 48.9%;
45+
opacity: 0.8;
46+
}
47+
#second{
48+
width: 1%;
49+
height: 40%;
50+
top: 9%;
51+
left: 49.25%;
52+
opacity: 0.8;
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+

wall-clock/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>clock</title>
8+
<link rel="stylesheet" href="index.css">
9+
</head>
10+
<body>
11+
<h1 class="heading">The Time</h1>
12+
<div class="clock">
13+
<div id="hour"></div>
14+
<div id="minute"></div>
15+
<div id="second"></div>
16+
</div>
17+
</body>
18+
<script src="index.js"></script>
19+
</html>

wall-clock/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
setInterval(() => {
2+
d = new Date();
3+
htime = d.getHours();
4+
mtime = d.getMinutes();
5+
stime = d.getSeconds();
6+
hrotation = 30*htime + mtime/2;
7+
mrotation = 6*mtime;
8+
srotation = 6*stime;
9+
10+
hour.style.transform = `rotate(${hrotation}deg)`;
11+
minute.style.transform = `rotate(${mrotation}deg)`;
12+
second.style.transform = `rotate(${srotation}deg)`;
13+
}, 1000);

0 commit comments

Comments
 (0)