-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathAnalog_And_Digital_Clock.html
295 lines (260 loc) · 6.62 KB
/
Analog_And_Digital_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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clock</title>
</head>
<body>
<div class="container">
<div class="clock">
<div class="circle" id="sc" style="--clr:#04fc43">
<i></i>
</div>
<div class="circle circle2" id="mn" style="--clr:#fee800">
<i></i>
</div>
<div class="circle circle3" id="hr" style="--clr:#ff2972">
<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 id="time">
<div id="hours" style="--clr:#ff2972">00</div>
<div id="minutes" style="--clr:#fee800">00</div>
<div id="seconds" style="--clr:#04fc43">00</div>
<div id="ampm">AM</div>
</div>
</div>
<script>
let hr = document.querySelector('#hr');
let mn = document.querySelector('#mn');
let sc = document.querySelector('#sc');
setInterval(() => {
let day = new Date();
let hh = day.getHours() * 30;
let mm = day.getMinutes() * 6;
let ss = day.getSeconds() * 6;
hr.style.transform = `rotateZ(${hh + (mm / 12)}deg)`;
mn.style.transform = `rotateZ(${mm}deg)`;
sc.style.transform = `rotateZ(${ss}deg)`;
let hours = document.getElementById('hours');
let minutes = document.getElementById('minutes');
let seconds = document.getElementById('seconds');
let ampm = document.getElementById('ampm');
let h = new Date().getHours();
let m = new Date().getMinutes();
let s = new Date().getSeconds();
let ap = h >= 12 ? "PM" : "AM";
if (h > 12) {
h = h - 12
}
h = (h < 10) ? "0" + h : h;
m = (m < 10) ? "0" + m : m;
s = (s < 10) ? "0" + s : s;
hours.innerHTML = h;
minutes.innerHTML = m;
seconds.innerHTML = s;
ampm.innerHTML = ap;
})
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #2f363e;
}
.container {
position: relative;
background: #2f363e;
/* min-height: 500px; */
border-radius: 20px;
border-top-left-radius: 225px;
border-top-right-radius: 225px;
box-shadow: 25px 25px 75px rgba(0, 0, 0, 0.75),
10px 50px 70px rgba(0, 0, 0, 0.25),
inset 5px 5px 10px rgba(0, 0, 0, 0.5),
inset 5px 5px 20px rgba(225, 225, 225, 0.2),
inset -5px -5px 15px rgba(0, 0, 0, 0.75);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.clock {
position: relative;
width: 450px;
height: 450px;
background: #2f363e;
border-radius: 50%;
box-shadow: 10px 50px 70px rgba(0, 0, 0, 0.25),
inset 5px 5px 10px rgba(0, 0, 0, 0.5),
inset 5px 5px 20px rgba(225, 225, 225, 0.2),
inset -5px -5px 15px rgba(0, 0, 0, 0.75);
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 30px;
}
.clock::before {
content: '';
position: absolute;
width: 8px;
height: 8px;
background: #2f363e;
border: 3px solid #fff;
border-radius: 50%;
z-index: 100000;
}
.clock span {
position: absolute;
inset: 20px;
color: #fff;
text-align: center;
transform: rotate(calc(30deg * var(--i)));
}
.clock span b {
font-size: 2em;
opacity: 0.25;
font-weight: 600;
display: inline-block;
transform: rotate(calc(-30deg * var(--i)));
}
.circle {
position: absolute;
width: 300px;
height: 300px;
border: 2px solid rgba(0, 0, 0, 0.25);
border-radius: 50%;
display: flex;
justify-content: center;
align-items: flex-start;
z-index: 10;
}
.circle i {
position: absolute;
width: 6px;
height: 50%;
background: var(--clr);
opacity: 0.75;
transform-origin: bottom;
transform: scaleY(0.5);
}
.circle:nth-child(1) i {
width: 2px;
}
.circle:nth-child(2) i {
width: 6px;
}
.circle2 {
width: 240px;
height: 240px;
z-index: 9;
}
.circle3 {
width: 180px;
height: 180px;
z-index: 8;
}
.circle::before {
content: '';
position: absolute;
top: -8.5px;
width: 15px;
height: 15px;
border-radius: 50%;
background: var(--clr);
box-shadow: 0 0 20px var(--clr),
0 0 60px var(--clr);
}
#time {
margin-bottom: 40px;
display: flex;
padding: 10px 20px;
font-size: 2em;
font-weight: 600;
border: 2px solid rgba(0, 0, 0, 0.5);
border-radius: 40px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5),
inset 5px 5px 20px rgba(255, 255, 255, 0.2),
inset -5px -5px 15px rgba(0, 0, 0, 0.75);
}
#time div {
position: relative;
width: 60px;
text-align: center;
font-weight: 500;
color: var(--clr);
}
#time div:nth-child(1)::after,
#time div:nth-child(2)::after {
content: ':';
position: absolute;
right: -4px;
}
#time div:last-child {
font-size: 0.5em;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
}
#time div:nth-child(2)::after {
animation: animate 1s steps(1) infinite;
}
@keyframes animate {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
}
</style>
</body>
</html>