Simple Countdown Timer using HTML CSS & JavaScript
If you want to make Simple Countdown Timer using JavaScript then you have come to the right place. Here I have shared a step-by-step tutorial for beginners on how to make a countdown timer. Earlier I shared with you tutorials like different types of stopwatches, countdown timers, digital clocks, etc.
Now the JavaScript timer that I am going to show is absolutely simple. As a result, if you are a beginner and know basic HTML, CSS, and javascript, you can easily create it. The Countdown Timer is a remarkable element used in a variety of business, e-commerce, and service websites. At times we notice countdowns on e-commerce websites or service websites.
Simple Countdown Timer
A countdown can be seen for some time before the launch of a product or service. JQuery is basically used to create a countdown timer that is used on a website. Here I will show you how to create a Simple Countdown Timer using Pure HTML, CSS, and JavaScript.
Below I have given a demo that will help you understand how it works. Here you will find the required source code.
See the Pen Untitled by Ground Tutorial (@groundtutorial) on CodePen.
I made four boxes on a blue background as you can see above. There will be countdowns for dates, hours, minutes, and seconds.
This means that the countdown will continue to be divided into days, hours, minutes, and seconds that you set. Text is used to indicate which box is pointing at which time in each box.
How to create Countdown Timer using javaScript
Now is the time to find out how I created this JavaScript Countdown Timer. For this, you must have a basic idea about HTML, CSS, and javascript. Here I have shared the necessary step-by-step tutorials.
Hopefully from this tutorial, you will know how to make a Simple Countdown Timer. If there is any problem then of course I can let you know by commenting below. You can use the download button below to download the complete source code.
Step 1: Html code of Countdown Timer
The following code is the HTML code needed to create this countdown timer. Here I have put all the HTML codes together. I have made four boxes here. The days, hours, minutes, and seconds can be seen in the four boxes, respectively.
One text and one number have been used in that box. Texts will help you understand which box indicates which time and the numbers will show the time.
Step 2: Design the webpage
I designed that page using the following codes. The background color of the webpage here is blue. Transform: translate (-50%, -50%), top: 50%, left: 50%. The countdown timer is placed in the middle of the webpage.
Step 3: Basic structure of timer
Now the basic structure of the counter timer has been created. Here the width of the basic structure: 95vw and max-width: 900px. The distance between each box is 10 px and the boxes are width: 28vmin, height: 29vmin.
Although no background color has been used for any of the elements here. So you can't see the size of the elements. Next time I will use the background color so that you do not see the size and height of the elements.
Step 4: Design the time boxes
Now the numbers have been designed. The background color of these numbers is white. Font-size: 4.2em has been used to create text sizes.
Step 5: Design the text in the box
Now the texts are designed to be seen on top of each box. These texts will help you to know which box is pointing at which time. The background color of the boxes is light yellow and the box-shadow is used which enhances the beauty.
Step 6: JavaScript of Simple Countdown Timer
We have designed a Simple Countdown Timer using HTML and CSS above. Now it needs to be implemented with the help of JavaScript. I have fully explained the reason for using each line here.
The first four lines are used to determine the constant of the ID functions in each box. Because we know that no HTML element can be used directly in JavaScript. One has to determine the global constant for them. Then time is taken from the device using the new date method.
Simple Countdown Timer Source Code
Hopefully, you have learned from the above tutorial how I have created a JavaScript countdown timer. However, for many people who only want to take the source code, I have given the source code below.
The box below contains the source code. If you want, you can copy those codes directly and use them in your work.
See the Pen Untitled by Ground Tutorial (@groundtutorial) on CodePen.
If you want to download the source code to create a Simple Countdown Timer, you can use the button below.
Create an HTML file before using the code above. Then copy those codes below and add them to the file. Be sure to comment on how you like this Simple Countdown Timer tutorial.
Comments
Post a Comment
Tell me what you think ??😎