样式:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/fbf9f288b7d5ff318fe72d0ba0eac4d3.png)
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
p {
width: 700px;
margin: 50px auto;
font-size: 30px;
font-weight: 700;
color: red;
}
</style>
</head>
<body>
<div>
<p id="aa"></p>
<p id="bb"></p>
<p id="cc"></p>
</div>
<script type="text/javascript">
function GetInterval(start, end) {
this.start = start;
this.end = end;
var interval = end - start;
interval /= 1000;
this.day = function () {
day = Math.round(interval / 60 / 60 / 24);
return day;
},
this.hour = function () {
hour = Math.round(interval / 60 / 60 % 24);
return hour;
},
this.minute = function () {
minute = Math.round(interval / 60 % 60);
return minute;
},
this.second = function () {
second = Math.round(interval % 60);
return second;
}
}
function chunjie() {
var d1 = new Date();
var d2 = new Date(2030, 1, 1);
var get1 = new GetInterval(d1, d2);
var time = '距2030年春节还有 倒计时:' + get1.day() + '天' + get1.hour() + '时' + get1.minute() + '分' + get1.second() + '秒';
var gar = document.getElementById("aa");
gar.innerHTML = time;
setTimeout(chunjie, 1000);
}
chunjie();
</script>
</body>
</html>