<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1 {
width: 500px;
height: 500px;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgb(241, 213, 218);
}
.box {
width: 100%;
height: 50px;
display: flex;
justify-content: space-around;
align-content: space-around;
}
.box div {
text-align: center;
line-height: 50px;
width: 50px;
height: 50px;
background-color: rgb(200, 239, 244);
}
</style>
</head>
<body>
<div class="box1">
<h3>今天是。。</h3>
<h1>下班倒计时</h1>
<div class="box">
<div></div>
<div></div>
<div></div>
</div>
</div>
<script>
const h3 = document.querySelector('h3')
const time = new Date()
h3.innerHTML = `今天是${time.getFullYear()}年${time.getMonth() + 1}月${time.getDate()}日`
const box = document.querySelectorAll('.box div')
function getNow() {
const now = +new Date()
const last = +new Date(' 2025-7-16 12:00:00 ')
let n = (last - now) / 1000
let h = parseInt(n / 60 / 60 % 24)
let m = parseInt(n / 60 % 60)
let s = parseInt(n % 60)
h = h < 10 ? '0' + h : h
m = m < 10 ? '0' + m : m
s = s < 10 ? '0' + s : s
box[0].innerHTML = h
box[1].innerHTML = m
box[2].innerHTML = s
}
getNow()
setInterval(getNow, 1000)
</script>
</body>
</html>
倒计时:可以用来倒计时假期
最新推荐文章于 2026-01-09 14:37:10 发布
1288

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



