<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景时钟</title>
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
color: #fff;
font-family: Arial, sans-serif;
overflow: hidden;
}
.clock-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: -1;
}
.clock {
font-size: 10vw;
text-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
opacity: 0.3;
}
.content {
text-align: center;
z-index: 1;
background-color: rgba(0, 0, 0, 0.7);
padding: 30px;
border-radius: 10px;
}
h1 {
margin-bottom: 20px;
}
a {
color: #0ff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="clock-container">
<div class="clock" id="clock"></div>
</div>
<div class="content">
<h1>背景时钟示例</h1>
<p>这是一个显示在背景上的透明时钟效果</p>
<p>当前时间会实时更新</p>
</p>
</div>
<script>
function updateClock() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
}
// 初始加载时更新时钟
updateClock();
// 每秒更新一次时钟
setInterval(updateClock, 1000);
</script>
</body>
</html>
1188

被折叠的 条评论
为什么被折叠?



