Create a loading spinner using pure CSS.

devggaurav

Gaurav

Posted on March 4, 2021

Create a loading spinner using pure CSS.

Hello everyone. In this quick tutorial, let's learn how to create a loading spinner using pure CSS in 3 easy steps!

Step 1 - HTML

Create the HTML structure we need (which is just 1 line)

<div class="spinner"></div>
Enter fullscreen mode Exit fullscreen mode

Step 2 - Add basic styles.

.spinner{
        width: 64px;
        height: 64px;
        border: 8px solid;
        border-color: #3d5af1 transparent #3d5af1 transparent;
        border-radius: 50%;
        animation: spin 1.2s linear infinite;
}
Enter fullscreen mode Exit fullscreen mode

Step 3 - Add the spin animation

 @keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
Enter fullscreen mode Exit fullscreen mode

That's it! we have created the loading spinner. Here is the final result.

spinner

Thank u๐Ÿ˜€

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
devggaurav
Gaurav

Posted on March 4, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About