-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
147 lines (134 loc) · 4.35 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Clock</title>
<meta name="title" content="CSS Clock - A CSS powered clock" />
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🕓</text></svg>"
/>
<style>
:root {
--h: 160;
--bg: var(--h) 28% 60%;
--color: var(--h) 100% 6%;
--shadow-color: var(--h) 10% 40%;
}
@property --seconds {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --minutes {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --hours {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
body {
overflow: hidden;
margin: 0;
background-color: hsl(var(--bg));
display: grid;
place-items: center;
height: 100svh;
width: 100svw;
h1 {
display: none;
}
*,
*::after,
*::before {
content: "";
grid-area: 1/1;
place-self: center;
aspect-ratio: 1;
animation-fill-mode: forwards;
box-shadow:
0 3px 5px -2px hsl(var(--shadow-color) / 0.2),
0 7px 14px -5px hsl(var(--shadow-color) / 0.3);
}
}
div {
width: min(80vh, calc(100vw - 4rem));
display: grid;
background-image: conic-gradient(
from var(--seconds),
transparent,
hsl(var(--color) / 0.15)
);
animation: 60s seconds linear infinite;
}
div::after {
width: 80%;
background-image: conic-gradient(
from var(--minutes),
transparent,
hsl(var(--color) / 0.25)
);
animation: 3600s minutes linear infinite;
}
div::before {
width: 60%;
background-image: conic-gradient(
from var(--hours),
transparent,
hsl(var(--color) / 0.35)
);
animation: 43200s hours linear infinite;
}
@keyframes seconds {
from {
--seconds: var(--start-seconds);
}
to {
--seconds: calc(var(--start-seconds) + 1turn);
}
}
@keyframes minutes {
from {
--minutes: var(--start-minutes);
}
to {
--minutes: calc(var(--start-minutes) + 1turn);
}
}
@keyframes hours {
from {
--hours: var(--start-hours);
}
to {
--hours: calc(var(--start-hours) + 1turn);
}
}
</style>
<script>
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes() + seconds / 60;
const hours = now.getHours() + minutes / 60;
document.documentElement.style.setProperty(
"--start-seconds",
`${seconds * 6}deg`,
);
document.documentElement.style.setProperty(
"--start-minutes",
`${minutes * 6}deg`,
);
document.documentElement.style.setProperty(
"--start-hours",
`${hours * 30}deg`,
);
</script>
</head>
<body>
<h1>CSS Clock</h1>
<div></div>
</body>
</html>