指定时间倒计时
春节临近 今天就搞个放假倒计时吧
时间可以在以下随意更改
<style>
#haha{
font-size: 70px;
position: fixed;
top: 30px;
left: 100px;
}
</style>
<title>放假倒计时</title>
<div id="haha">
<p class="shanshuo" style="color: black">....................................................................</p>
<div id="lala">
距放假还有:
<span id='daya'></span>天
<span id='hoursa'></span>小时
<span id='minua'></span>分
<span id='secoa'></span>秒
<span id='secoas'></span>
</div>
<p class="shanshuo" style="color: black">....................................................................</p>
</div>
<script>
function time(){
// 当前时间
var nt=new Date();
// 指定时间
var lt=new Date(2019,0,26,15,30,0);
// 计算两个时间差
var diff=lt.getTime()-nt.getTime();
// 计算天数
var days= parseInt(diff/(24*60*60*1000));
// document.write(days)
// 计算完天数剩余的毫秒数
diff=diff%(24*60*60*1000);
// 计算小时
var hour=parseInt(diff/(60*60*1000));
// 计算分钟
diff=diff%(60*60*1000);
var minutes=parseInt(diff/(60*1000));
// 计算分钟后的毫秒数
diff=diff%(60*1000);
// 计算秒
var sec=parseInt(diff/(1000));
diff=parseInt(diff%(1000));
document.getElementById('daya').innerHTML=days;
document.getElementById('hoursa').innerHTML=hour;
document.getElementById('minua').innerHTML=minutes;
document.getElementById('secoa').innerHTML=sec;
document.getElementById('secoas').innerHTML=diff;
}
time();
setInterval(function () {
time();
},100);
// 以下为字体闪烁
var lala=document.getElementById('lala');
var s=document.getElementsByTagName('p')[0];
var s1=document.getElementsByTagName('p')[1];
var timer;
timer=setInterval(function(){
var b = parseInt(Math.random()*255);
var c = parseInt(Math.random()*255);
var d = parseInt(Math.random()*255);
s.style.color='rgb('+b+','+c+','+d+')';
s1.style.color='rgb('+b+','+c+','+d+')'
},100);
var timer1;
timer1=setInterval(function(){
var b = parseInt(Math.random()*255);
var c = parseInt(Math.random()*255);
var d = parseInt(Math.random()*255);
lala.style.color='rgb('+b+','+c+','+d+')'
},200)
</script>