批改状态:合格
老师批语:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<style type="text/css">
.content{ height: 400px; width: 800px; background-color: pink; margin: 0 auto; position: relative;}
.main{ color: #fff; position:absolute; top: 120px; left: 150px; }
</style>
</head>
<body>
<script>
function showTime(){
var timestamp=new Date().getTime();
var chuntime=(new Date("2019/02/05 00:00:00")).getTime();
var countdown=(chuntime-timestamp)/1000;
var day = Math.floor(countdown/3600/24); //倒计时还有多少天
var hr = Math.floor(countdown/3600%24); //倒计时还有多少小时(%取余数)
var min = Math.floor(countdown/60%60); //倒计时还有多少分钟
var sec = Math.floor(countdown%60);
$('.main').text("2019年农历春节倒计时:"+day+'天'+hr+'小时'+min+'分'+sec+'秒');
setTimeout(showTime,1000);
}
showTime();
</script>
<div class="content">
<div class="main"></div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号