The Wayback Machine - https://web.archive.org/web/20240711161341/https://www.geeksforgeeks.org/how-to-create-a-dot-loading-animation-using-html-and-css/
Open In App

How to Create a Dot loading Animation using HTML and CSS?

Last Updated : 14 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The Dot Loading animation can be used to enhance the user interface of a website, it can be added while the website loads. This animation can be easily created using HTML and CSS.

HTML Code: In this section we will create the basic structure of the dot loader using a div tag which will have some span tags inside of it.




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width,
                 initial-scale=1.0">
  <title>Dots Loading Animation</title>
</head>
<style>
    
<body>
  <div class="loader">
    <span></span>
    <span ></span>
    <span ></span>
    <span ></span>
    <span></span>
    <span></span>
  </div>
</body>
</html>


CSS Code: In this section first we will create the dots structure using some basic CSS properties and then in order to create the animation we will use @keyframes rule and use the transformX() function to produce the desired effect.




<style>
body{
  margin: 0;
  padding: 0;
 }
  
 .loader{
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   display: flex;
   align-items: center;
     
 }
 /* Creating the dots */
 span{
   height: 25px;
   width: 25px;
   margin-right: 10px;
   border-radius: 50%;
   background-color: green;
   animation: loading 1s linear infinite;
 }
 /* Creating the loading animation*/
 @keyframes loading {
   0%{
    transform: translateX(0);
   }
   25%{
    transform: translateX(15px);
   }
   50%{
    transform: translateX(-15px);
   }
   100%{
    transform: translateX(0);
   }
     
 }
  
span:nth-child(1){
  animation-delay: 0.1s;
}
span:nth-child(2){
  animation-delay: 0.2s;
}
span:nth-child(3){
  animation-delay: 0.3s;
}
span:nth-child(4){
  animation-delay: 0.4s;
}
span:nth-child(5){
  animation-delay: 0.5s;
}
</style>


Complete Code:  It is the combination of the above two code sections.




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" 
        content="width=device-width,
                 initial-scale=1.0">
  <title>Dots loading animation</title>
</head>
<style>
  body{
  margin: 0;
  padding: 0;
 }
  
 .loader{
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   display: flex;
   align-items: center;
     
 }
 /* Creating the dots */
 span{
   height: 25px;
   width: 25px;
   margin-right: 10px;
   border-radius: 50%;
   background-color: green;
   animation: loading 1s linear infinite;
 }
 /* Creating the loading animation*/
 @keyframes loading {
   0%{
    transform: translateX(0);
   }
   25%{
    transform: translateX(15px);
   }
   50%{
    transform: translateX(-15px);
   }
   100%{
    transform: translateX(0);
   }
     
 }
span:nth-child(1){
  animation-delay: 0.1s;
}
span:nth-child(2){
  animation-delay: 0.2s;
}
span:nth-child(3){
  animation-delay: 0.3s;
}
span:nth-child(4){
  animation-delay: 0.4s;
}
span:nth-child(5){
  animation-delay: 0.5s;
}
</style> 
<body>
  <div class="loader">
    <span></span>
    <span ></span>
    <span ></span>
    <span ></span>
    <span></span>
    <span></span>
  </div>
</body>
</html>


Output: 



Similar Reads

How to Create Loading Blur Text Animation Effect using HTML and CSS ?
The blur text animation is known as the Smoky effect and it is used to give our text a blurry animation. The text blurs linearly in one direction and then reappears. Approach: The approach of this article is quite simple. We are animating the blur effect using the blur() function. Then we are using n-th child property to apply the animation delay.
3 min read
Double-Dot “..” vs. Triple-Dot “…” in Git Commit Ranges
Git, the distributed version control system, is a powerful tool for tracking changes in source code during software development. Among its many features, the syntax for specifying commit ranges is important for managing and understanding changes in your repository. Two such syntaxes are the double-dot `..` and the triple-dot `....` While they might
4 min read
Create a Button Loading Animation in HTML CSS & JavaScript
A "Button Loading Animation" in HTML, CSS, and JavaScript is a user interface element that temporarily transforms a button into a loading state with a spinner or animation to indicate ongoing processing or data retrieval, providing feedback to users during asynchronous tasks. Approach: HTML page with a user form, including username, password fields
2 min read
How to Create Animation Loading Bar using CSS ?
Loading Bar with animation can be created using HTML and CSS. We will create a Loader that is the part of an operating system that is responsible for loading programs and libraries. The progress bar is a graphical control element used to visualize the progression of an extended computer operation, so here we use the progress bar as an animation in
3 min read
How to Create Circle Loading Animation Effect using CSS ?
In this article, we will see how to create a circle-loading animation using HTML and CSS, along with understanding its basic implementation through the example. Generally, Loading Animation is utilized to wait for the content to be fully loaded on the webpage. If some pages don't contain the loader, then the user may think that the webpage is not r
6 min read
How to Create Page Loading Animation Effect using jQuery ?
In this article, we are going to learn how to create page loading animation effect (Please Wait, Loading... animation) using jQuery, A "Please Wait, Loading..." animation is a visual indication shown during data retrieval or processing, assuring users that content is being fetched or actions are in progress. Syntax $(document).ready(function() { //
6 min read
Loading Text Animation Effect using CSS
There are a lot of animations possible in CSS and today we will look at the loading text animation. The basic idea behind the working of this animation is the application of animation delay. Every alphabet is delayed by .1s so that each alphabet animates with a little delay and give the loading animation. HTML Code: It is used to create the basic s
3 min read
Primer CSS Toast with Loading Animation
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by object-oriented CSS principles, functional CSS, an
3 min read
How to show Page Loading div until the page has finished loading?
There are a lot of ways in which we can show a loading div but we have figured out the most optimal solution for you and that too in pure vanilla JavaScript. We will use the document.readyState property. When the value of this property changes, a readystatechange event fires on the document object. The document.readyState property can return these
2 min read
How to create windows loading effect using HTML and CSS ?
In this article, we are going to create a window loading effect before the lock screen appears using HTML and CSS. Glimpse of the Windows Loading Effect: Approach: Create an HTML file that contains HTML div in which we are giving the loader effect.Then we create 5 span elements which are used for creating inline elements.Then we have to use @keyfra
4 min read
three90RightbarBannerImg