概述
天猫倒计时,网页倒计时JavaScript特效,距离2015-11-11日倒计时:
距离活动结束还有
00时
00分
00秒
99
天猫倒计时,网页倒计时JavaScript代码:
body {
}
.sp-banner-countdown {
width: 500px;
height: 55px;
/*position: absolute;
top: 375px;
right: 282px;*/
/*background-image: url(http://a.vpimg3.com/upload/actpics/act/sp/branches/pc_sp/act-20151111/img/warm/countdownbg.d8d93f93.png);*/
background-position: 0 0;
background-repeat: no-repeat;
text-align:center;
background:#ccc;
height:150px;
}
.sp-banner-countdown .banner-cd-cont {
height: 80px;
overflow: hidden;
line-height: 50px;
width:400px;
margin:0px auto;
}
.sp-banner-countdown .banner-cd-s {
float: left;
display: block;
/*margin-right: 28px;*/
width: 52px;
height: 50px;
text-align: right;
font-size: 32px;
color: #fff;
letter-spacing: 5px;
font-family: bebas,tahoma;
background:url(http://resource.520.cn/img/active/flashbuy/num_bg.png) center left repeat-x;
}
.sp-banner-countdown .b-cd-s {
color: #ffbb45
}
.sp-banner-countdown .banner-cd-hd {
/*position: absolute;
top: 3px;
left: 136px;*/
height: 20px;
color: #fff;
font-family: microsoft Yahei;
line-height: 20px;
font-size: 14px;
margin:10px auto;
}
.sp-banner-countdown .cd-d {
text-indent:4px;
letter-spacing: 9px;
}
.sp-banner-countdown .cd-h {
text-indent:4px;
letter-spacing: 9px;
}
.sp-banner-countdown .cd-m,.sp-banner-countdown .cd-s {
text-indent:4px;
letter-spacing: 9px;
}
.banner-text {
float:left;
font-size:24px;
}
.sp-banner-countdown .banner-cd-cont .cd-w {width:52px;letter-spacing:9px;text-indent:4px;}
String.prototype.padLeft = function (padChar, width) {
var ret = this;
while (ret.length < width) {
if (ret.length + padChar.length < width) {
ret = padChar + ret;
}
else {
ret = padChar.substring(0, width - ret.length) + ret;
}
}
return ret.replace(/(.)(?=[^$])/g, "$1");
};
//window.onload = function () {
// window.setInterval(function () { ShowCountDown('2015-11-12'); }, interval);
//}
$(function () {
window.setInterval(function () { ShowCountDown('2015-11-12'); }, interval);
})
var interval = 1,count=99;
function ShowCountDown(str) {
var now = new Date();
var year = str.split('-')[0];
var month = str.split('-')[1];
var day = str.split('-')[2];
var endDate = new Date(year, month - 1, day);
var leftTime = endDate.getTime() - now.getTime();
var leftsecond = parseInt(leftTime / 1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var day1 = Math.floor(leftsecond / (60 * 60 * 24));
var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600);
var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60);
var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60);
count=count <= 0?99:count - 1;
var microsecond = count;
var cdh = document.getElementById("J-cd-h");
var cdm = document.getElementById("J-cd-m");
var cds = document.getElementById("J-cd-s");
var cdw = document.getElementById("J-cd-w");
cdh.innerHTML = (hour + "").padLeft('0', 2);
cdm.innerHTML = (minute + "").padLeft('0', 2);
cds.innerHTML = (second + "").padLeft('0', 2);
cdw.innerHTML = (microsecond + "").padLeft('0', 2);
}
最后
以上就是开放红牛为你收集整理的html天猫倒计时代码,天猫倒计时,网页倒计时JavaScript代码的全部内容,希望文章能够帮你解决html天猫倒计时代码,天猫倒计时,网页倒计时JavaScript代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复