2025春节大年初一倒计时代码
https://bbs.cnzv.cc/mpv.php/up-3565-1736778082.html<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2025春节大年初一倒计时</title>
<style>
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(to right, #ff7e5f, #feb47b);
color: white;
text-align: center;
padding: 50px;
}
h1 {
font-size: 3em;
margin-bottom: 20px;
}
#countdown {
font-size: 2em;
margin-bottom: 20px;
}
.container {
display: inline-block;
padding: 20px;
border-radius: 10px;
background: rgba(0, 0, 0, 0.5);
}
.time-box {
display: inline-block;
margin: 0 10px;
padding: 10px;
background: rgba(255, 255, 255, 0.2);
border-radius: 5px;
}
.time-box span {
display: block;
font-size: 1.5em;
}
.time-box b {
font-size: 2em;
}
</style>
</head>
<body>
<div class="container">
<h1>2025春节大年初一倒计时</h1>
<div id="countdown">
<div class="time-box"><span>天</span><b id="days"></b></div>
<div class="time-box"><span>时</span><b id="hours"></b></div>
<div class="time-box"><span>分</span><b id="minutes"></b></div>
<div class="time-box"><span>秒</span><b id="seconds"></b></div>
</div>
</div>
<script>
function updateCountdown() {
const targetDate = new Date('January 29, 2025 00:00:00').getTime(); // 修改为2025年新年
const now = new Date().getTime();
const timeDifference = targetDate - now;
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000);
document.getElementById('days').innerText = days;
document.getElementById('hours').innerText = hours;
document.getElementById('minutes').innerText = minutes;
document.getElementById('seconds').innerText = seconds;
}
setInterval(updateCountdown, 1000);
updateCountdown();
</script>
</body>
</html>
很应景哇~时光匆匆,面向未来,活好当下! 欣赏老大春节倒计时代码! 我表示压力很大 非常不错,感谢分享!
页:
[1]