
A pure JavaScript countdown clock that makes uses of CSS3 to flip days/hours/minutes/seconds slots when counting down.
How to use it:
Create the HTML for the countdown clock.
<div id="clock"></div> <div id="units"> <span>Days</span> <span>Hours</span> <span>Minutes</span> <span>Seconds</span> </div>
Put the Countdown.js at the bottom of the webpage.
<script src='countdown.js'></script>
Set the time the clock will countdown from.
window.onload = () => {
const deadline = new Date("December 23, 2018 13:00:00");
startTimer("clock", deadline)
};Animate the countdown clock with the following CSS/CSS3.
#clock span {
float: left;
text-align: center;
font-size: 60px;
margin: 0 2.5%;
color: #ffffff;
padding: 20px;
width: 20%;
border-radius: 20px;
box-sizing: border-box;
}
#clock span:nth-child(1) {
background: #C70039;
}
#clock span:nth-child(2) {
background: #FF5733;
}
#clock span:nth-child(3) {
background: #FFC300;
}
#clock span:nth-child(4) {
background: #C9E498;
}
#clock:after {
content: "";
display: block;
clear: both;
}
#units span {
float: left;
width: 25%;
text-align: center;
margin-top: 30px;
color: #D7DBDD;
text-transform: uppercase;
font-size: 13px;
letter-spacing: 2px;
text-shadow: 1px 1px 1px rgba(10, 10, 10, 0.7)
}
span.turn {
animation: turn 0.5s ease forwards;
}
@keyframes turn {
0% {
transform: rotateY(0deg)
}
100% {
transform: rotateY(360deg)
}
}






