请给我写一个绚丽的倒计时网页
时间: 2023-12-15 17:03:32 浏览: 21
好的,下面是一个简单的倒计时网页示例:
```HTML
<!DOCTYPE html>
<html>
<head>
<title>倒计时网页</title>
<style>
body {
background-color: black;
color: white;
font-size: 50px;
text-align: center;
margin-top: 20%;
}
</style>
</head>
<body>
<div id="countdown"></div>
<script>
// 设置倒计时目标日期
var countDownDate = new Date("May 1, 2022 00:00:00").getTime();
// 每秒更新倒计时
var x = setInterval(function() {
// 获取当前日期和时间
var now = new Date().getTime();
// 计算距离目标日期还有多久
var distance = countDownDate - now;
// 计算天、小时、分钟、秒
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// 显示倒计时
document.getElementById("countdown").innerHTML = days + "天 " + hours + "时 " + minutes + "分 " + seconds + "秒 ";
// 如果倒计时结束,停止更新
if (distance < 0) {
clearInterval(x);
document.getElementById("countdown").innerHTML = "倒计时结束!";
}
}, 1000);
</script>
</body>
</html>
```
这个网页会在页面中央显示一个绚丽的倒计时效果,直到设定的目标日期到达。你可以根据自己的需要修改样式和目标日期。