body {
background-color: #f1f1f1;
font-family: 'Montserrat', sans-serif;
}
.card {
margin: 0 auto;
padding: 50px;
display: block;
max-width: 500px;
width: 100%;
text-align: center;
background-color: #fff;
border-radius: 12px;
box-shadow: 0 10px 10px -5px #909090;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#countdown {
font-size: 48px;
}
top of page
bottom of page
var timeInSecs;
var ticker;
function startTimer(secs) {
timeInSecs = parseInt(secs);
ticker = setInterval("tick()", 1000);
}
function tick( ) {
var secs = timeInSecs;
if (secs > 0) {
timeInSecs--;
}
else {
clearInterval(ticker);
startTimer(5*60); // 4 minutes in seconds
}
var days= Math.floor(secs/86400);
secs %= 86400;
var hours= Math.floor(secs/3600);
secs %= 3600;
var mins = Math.floor(secs/60);
secs %= 60;
var pretty = ( (days < 10 ) ? "0" : "" ) + days + ":" + ( (hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs;
document.getElementById("countdown").innerHTML = pretty;
}
startTimer(5*60); // 4 minutes in seconds