-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (47 loc) · 1.19 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>LCD 数字时钟</title>
<style>
@font-face {
font-family: 'LCD';
src: url('./fonts/DSEG7Classic-Regular.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}
.lcd-clock {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'LCD', monospace;
font-size: 128px; /* 字体大小 */
color: white;
text-shadow: 0 0 5px #000, 0 0 10px #000, 0 0 15px #000, 0 0 20px #fff;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>
</head>
<body>
<div class="container"><div class="lcd-clock" id="clock">00:00:00</div></div>
<script>
function updateClock() {
var now = new Date();
var hours = now.getHours().toString().padStart(2, '0');
var minutes = now.getMinutes().toString().padStart(2, '0');
var seconds = now.getSeconds().toString().padStart(2, '0');
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
}
// 初始化时钟
updateClock();
// 每秒更新一次时钟
setInterval(updateClock, 1000);
</script>
</body>
</html>