-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
125 lines (111 loc) · 3.12 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
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
<!DOCTYPE html>
<html>
<head>
<title>Digital Clock</title>
<style>
body {
margin: 0;
padding: 0;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.clock {
font-size: 64px;
font-family: Arial, sans-serif;
color: white;
text-align: center;
padding: 20px;
border: 1px solid orange;
border-radius: 20px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
transition: transform 0.5s; /* add transition effect */
position: relative; /* add relative positioning */
}
.clock::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
background: linear-gradient(to right, #01fee6, #00ff7c);
border-radius: 20px;
animation: shine 5s infinite; /* add animation */
z-index: -1; /* send the shining line to the back */
}
@keyframes shine {
0% {
width: 0;
}
100% {
width: 100%;
}
}
.clock.grow {
transform: scale(5); /* scale up to 1.2 times original size */
}
.clock.shrink {
transform: scale(1); /* scale back to original size */
}
/* Media queries for responsiveness */
@media only screen and (max-width: 1920px) { /* for 2K resolution */
.clock {
font-size: 48px;
}
}
@media only screen and (max-width: 1366px) { /* for Full HD resolution */
.clock {
font-size: 36px;
}
}
@media only screen and (max-width: 1024px) { /* for HD resolution */
.clock {
font-size: 28px;
}
}
@media only screen and (max-width: 768px) { /* for tablet resolution */
.clock {
font-size: 24px;
}
}
@media only screen and (max-width: 480px) { /* for mobile resolution */
.clock {
font-size: 18px;
}
}
</style>
</head>
<body>
<div class="clock" id="clock"></div>
<script>
let grow = true;
function updateClock() {
const pakistanTime = new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Karachi" }));
let hours = pakistanTime.getHours();
let ampm = hours >= 12? 'PM' : 'AM';
hours = hours % 12;
hours = hours? hours : 12; // the hour '0' should be '12'
const minutes = pakistanTime.getMinutes().toString().padStart(2, '0');
const seconds = pakistanTime.getSeconds().toString().padStart(2, '0');
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds} ${ampm}`;
}
function animateClock() {
const clock = document.getElementById('clock');
if (grow) {
clock.classList.add('grow');
clock.classList.remove('shrink');
} else {
clock.classList.add('shrink');
clock.classList.remove('grow');
}
grow =!grow;
}
setInterval(updateClock, 1000);
setInterval(animateClock, 5000); // animate every 5 seconds
updateClock();
</script>
</body>
</html>