写一段倒计时的代码,要白色背景,指针形式的
时间: 2023-02-21 11:04:09 浏览: 37
<script type="text/javascript">
var countDownDate = new Date("Current date").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("demo").innerHTML = "<div style='background:#FFF;width:150px;height:150px;border-radius:50%;position:relative;'><div style='position:absolute;width:150px;height:150px;border-radius:50%;background:#000;'></div><div style='position:absolute;width:150px;height:150px;border-radius:50%;'><div style='width:100%;height:100%;text-align:center;line-height:150px;font-size:20px;color:#FFF;'>"+days+"天 "+hours+"小时 "+minutes+"分 "+seconds+"秒"+"</div></div></div>";
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "已到时间";
}
}, 1000);
</script>
<p id="demo"></p>