238 lines
7.1 KiB
HTML
238 lines
7.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>简单时钟</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
font-family: 'Arial', sans-serif;
|
|
}
|
|
|
|
.clock-container {
|
|
text-align: center;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
backdrop-filter: blur(10px);
|
|
border-radius: 20px;
|
|
padding: 40px;
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.clock {
|
|
font-size: 4rem;
|
|
font-weight: bold;
|
|
color: #ffffff;
|
|
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
|
margin-bottom: 20px;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
|
|
.date {
|
|
font-size: 1.5rem;
|
|
color: #f0f0f0;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.day {
|
|
font-size: 1.2rem;
|
|
color: #e0e0e0;
|
|
}
|
|
|
|
.seconds {
|
|
color: #ffeb3b;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="clock-container">
|
|
<div class="date" id="date"></div>
|
|
<div class="clock" id="clock"></div>
|
|
<div class="day" id="day"></div>
|
|
</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');
|
|
|
|
// 获取日期
|
|
const year = now.getFullYear();
|
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
const day = now.getDate().toString().padStart(2, '0');
|
|
|
|
// 获取星期
|
|
const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
|
const dayOfWeek = days[now.getDay()];
|
|
|
|
// 更新显示
|
|
document.getElementById('clock').innerHTML =
|
|
`${hours}:${minutes}:<span class="seconds">${seconds}</span>`;
|
|
document.getElementById('date').textContent = `${year}年${month}月${day}日`;
|
|
document.getElementById('day').textContent = dayOfWeek;
|
|
}
|
|
|
|
// 立即更新一次
|
|
updateClock();
|
|
|
|
// 每秒更新
|
|
setInterval(updateClock, 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>简约时钟</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
|
height: 100vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.clock-container {
|
|
text-align: center;
|
|
padding: 60px 80px;
|
|
background: rgba(255, 255, 255, 0.03);
|
|
backdrop-filter: blur(20px);
|
|
border-radius: 30px;
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
box-shadow: 0 25px 45px rgba(0, 0, 0, 0.3);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.clock-container:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 35px 65px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.time-display {
|
|
font-size: 6rem;
|
|
font-weight: 200;
|
|
color: #ffffff;
|
|
letter-spacing: 0.05em;
|
|
margin-bottom: 20px;
|
|
text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.time-display:hover {
|
|
text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
|
|
}
|
|
|
|
.date-display {
|
|
font-size: 1.2rem;
|
|
font-weight: 300;
|
|
color: rgba(255, 255, 255, 0.7);
|
|
letter-spacing: 0.1em;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.seconds {
|
|
font-size: 2rem;
|
|
font-weight: 100;
|
|
color: rgba(255, 255, 255, 0.5);
|
|
margin-left: 10px;
|
|
vertical-align: super;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.time-display {
|
|
font-size: 4rem;
|
|
}
|
|
|
|
.clock-container {
|
|
padding: 40px 50px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.time-display {
|
|
font-size: 3rem;
|
|
}
|
|
|
|
.date-display {
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.clock-container {
|
|
padding: 30px 40px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="clock-container">
|
|
<div class="time-display" id="time">
|
|
<span id="hours">00</span>:<span id="minutes">00</span><span class="seconds" id="seconds">00</span>
|
|
</div>
|
|
<div class="date-display" id="date">
|
|
2025年1月1日 星期三
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function updateClock() {
|
|
const now = new Date();
|
|
|
|
// 获取时间
|
|
const hours = String(now.getHours()).padStart(2, '0');
|
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
|
|
// 获取日期
|
|
const year = now.getFullYear();
|
|
const month = now.getMonth() + 1;
|
|
const day = now.getDate();
|
|
const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
|
|
const weekday = weekdays[now.getDay()];
|
|
|
|
// 更新显示
|
|
document.getElementById('hours').textContent = hours;
|
|
document.getElementById('minutes').textContent = minutes;
|
|
document.getElementById('seconds').textContent = seconds;
|
|
document.getElementById('date').textContent = `${year}年${month}月${day}日 ${weekday}`;
|
|
}
|
|
|
|
// 初始化时钟
|
|
updateClock();
|
|
|
|
// 每秒更新一次
|
|
setInterval(updateClock, 1000);
|
|
|
|
// 添加微妙的动画效果
|
|
const timeDisplay = document.querySelector('.time-display');
|
|
setInterval(() => {
|
|
timeDisplay.style.opacity = '0.95';
|
|
setTimeout(() => {
|
|
timeDisplay.style.opacity = '1';
|
|
}, 50);
|
|
}, 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|