添加倒计时


技术卡片99 阅3 评

之前有过网站正计时,现在有了倒计时。这次的倒计时是从Tiger_Root博客要来的,进行了简化小改。

考研倒计时


<style>  
.gn_box{     
border: none;     
border-radius: 15px; }  
.gn_box {     
padding: 10px 10px;     
margin: 10px;     
margin-bottom: 16px;     
text-align: center; 
background-color: #000; //背景颜色}  
.tttt{color:#D8D0C0;//标题颜色}
.time{color: #D8D0C0; //时间文字颜色
font-size: 18px;}   
</style>  
<div class="gn_box">      
  <h3>
    <font class="tttt">考研倒计时</font>
  </h3>
<center> 
<div id="CountMsg" class="HotDate">
<span id="t_d" class="time"> 天</span>
<span id="t_h" class="time"> 时</span>
<span id="t_m" class="time"> 分</span>
<span id="t_s" class="time"> 秒</span>
</div>
</center> 
<script type="text/javascript">  
function getRTime() {        
var EndTime = new Date('2021/12/22 00:00:00'); /**目标时间*/   
var NowTime = new Date();       
var t = EndTime.getTime() - NowTime.getTime();              
var d = Math.floor(t / 1000 / 60 / 60 / 24);              
var h = Math.floor(t / 1000 / 60 / 60 % 24);              
var m = Math.floor(t / 1000 / 60 % 60);              
var s = Math.floor(t / 1000 % 60);      
var day = document.getElementById("t_d");     
if (day != null) {         
day.innerHTML = d + " 天";        
}     
var hour = document.getElementById("t_h");     
if (hour != null) {         
hour.innerHTML = h + " 时";       
}     
var min = document.getElementById("t_m");     
if (min != null) {         
min.innerHTML = m + " 分";        
}     
var sec = document.getElementById("t_s");     
if (sec != null) {         
sec.innerHTML = s + " 秒";     
} 
}      
setInterval(getRTime, 1000);      
</script> 
</div>
最后更新 2021-11-27
评论 ( 3 )
OωO
隐私评论
  1. 这个样式写得很合我心水,先收藏一波。

    6个月前回复
  2. jellyw

    偷走@(吐舌)

    7个月前回复
    1. @jellyw

      很快啊@(真棒)

      7个月前回复