NewYear Countdown with Javascript

course from Brad Traversy

Github code

Features:

dynamic new year 

with 1 second loader

cal the difference between new year and current

HTML

the year is a dynamic new year display
the countdown includes the days, minutes, hours, and seconds
loader image shows when page loads

CSS
add the background overlay with ::after
and all the other upper layer

First, hide the countdown to show the loader

For a responsive browser with media

JS
select elements DOM

get current year with Date().getFullYear()
newYearTime is current year +1 with date and time
new year show in the year section

every second the function runs once.
calculate the difference between new year's time and the current time.
calculate the days, hours, minutes, and seconds of difference
seconds total=diff/1000 and the %60 is extra seconds
minutes total=diff/1000/60
days total=diff/1000/60/60/24
hours total=diff/1000/60/60
and with ?...:... to make sure every time is two numbers

After page loaded one second, the loading hide, and show the countdown

Popular posts from this blog

Fancyapps — easily build overlay windows with carousel

Thoughts about Progressive Web App

Meet Mantine: A TS-Based Open-Source React Components Library