Day # 64: Animated countdown
Countdowns are a good functionality to have for some websites, especially if you are creating an online store that may offer certain discounts. With that in mind, I decided to create, for today’s website, an animated countdown for the last three seconds.
The key here is to have 4 span’s for each one of the numbers in the countdown:
<span class="in">3</span>
<span>2</span>
<span>1</span>
<span>0</span>
Then we can set these spans to an active class with Javascript in order to show them one at a time until the countdown is over.
That bouncy effect can be achieved by setting an animation this way:
@keyframes show {
0% {
transform: translate(-50%, -50%) scale(0);
}
30% {
transform: translate(-50%, -50%) scale(1.4);
}
100% {
transform: translate(-50%, -50%) scale(1);
}
}
Comments
Post a Comment