JS图片倒计时

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>逼真图片倒计时</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
.time{width:200px;height:25px;overflow:hidden;}
.time span{float:left;line-height:25px;height:25px;overflow:hidden;}
.time span.danwei{padding:0 1px;}
.clear{height:0;clear:both;overflow:hidden;}
</style>
</head>
<body>
距离发射升空还有:
<div class="time" id="time1">
	<span><img id="hour_01" alt="" src="time_number.jpg"></span>
	<span><img id="hour_02" alt="" src="time_number.jpg"></span>
	<span class="danwei">:</span>
	<span><img id="minute_01" alt="" src="time_number.jpg"></span>
	<span><img id="minute_02" alt="" src="time_number.jpg"></span>
	<span class="danwei">:</span>
	<span><img id="second_01" alt="" src="time_number.jpg"></span>
	<span><img id="second_02" alt="" src="time_number.jpg"></span>
	<br class="clear">
</div>
<script type="text/javascript">
var overa;
overa = new Date(2012, 02, 16, 00, 00);///第数日时间当时间超过999小时
	var localNow = new Date();
	function clock1(){
        var local = new Date();
        var intDiff = overa.getTime() - local.getTime();
        if(intDiff <= 0){document.getElementById('time1').innerHTML = "活动已结束!";//显示活动结束
	return false;}
	// 除于自己等价那部分减去老大那等价部分
        var day    = Math.floor(intDiff / (1000 * 60 * 60 * 24));    
        var hour   = Math.floor(intDiff / (1000 * 60 * 60)) - (day * 24);
        var minute = Math.floor(intDiff / (1000 * 60)) - (day * 24 * 60) - (hour * 60);
        var second = Math.floor(intDiff / 1000) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
       
        if (day <= 9) day = '0' + day;
        if (hour <= 9) hour = '0' + hour;
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;
        document.getElementById('hour_01').style.marginTop = (hour.toString().substr(0,1)) * (-25) +'px';
        document.getElementById('hour_02').style.marginTop = (hour.toString().substr(1,1)) * (-25) +'px';
        
        document.getElementById('minute_01').style.marginTop = (minute.toString().substr(0,1)) * (-25) +'px';
        document.getElementById('minute_02').style.marginTop = (minute.toString().substr(1,1)) * (-25) +'px';
        document.getElementById('second_01').style.marginTop = (second.toString().substr(0,1)) * (-25) +'px';
        document.getElementById('second_02').style.marginTop = (second.toString().substr(1,1)) * (-25) +'px';
        setTimeout("clock1()", 1000);
        }
	clock1();

</script>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值