Digital Clock using JavaScript
Hello Guys! In this blog, I'm going to explain to you how to make a digital clock using javascript. You can use this project on your website to show the time to your users. I know users can see the time on their systems but you can use this project to show different time zones. This will be a step-by-step guide including HTML and CSS. Let's get started 🚀.
Let's cover the HTML part
HTML is a markup language. We use HTML to make the skeleton of a website.
Now let's import the font awesome CDN in our HTML head tag. fontawesome is a library that is used for icons in a website.
Now let's import the fonts using Google Fonts API. Below is the code for Poppins Font. Paste the below code in head tag.
In the below HTML code, we have created a container that has a card div and inside the card div, we have a time display div with id 'clockDisplay' and onload attribute to invoke showTime() function on website loads.
Next we have calculate button which have onclick attribute with calculateLoan() function
Here is the Final HTML Code
Output Till Now
Let's understand CSS Part
In the below CSS code,
- We declare a * selectors to set the font Poppins that we have imported in our head tag.
- Next we declare a body selector which consists of styles for dark mode and aligns all elements in the body to the center.
- Next, we have a container and card with glassmorphism effect. I have created this Glassmorphic effect using Glass UI.