Limited Period Offer : 20% Discount on online/offline courses, for more details call/whatsapp

Creating a Spinner Using Pure HTML and CSS

1 min read
1 year ago By Mitali Gupta
Creating a Spinner Using Pure HTML and CSS

Spinners are a common UI element used to indicate that a process is ongoing and to provide visual feedback to users. In this article, we will explore how to create a spinner using pure HTML and CSS. By the end, you'll have a stylish spinner that rotates indefinitely, adding a touch of dynamism to your web pages.


**Step 1: HTML Markup** To begin, let's set up the HTML structure for our spinner. Place the following code within the body of your HTML file:
<div class="outer">
  <div></div>
</div>

Step 2: Styling the Spinner Next, we'll style the spinner using CSS. Add the following code within the tags of your HTML file or in a separate CSS file linked to your HTML file:

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

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
  • Define the "outer" class with a 64px*64px container.
  • Set the border-radius property to 50% for creating a perfect circle.
  • Use the animation property to apply the "spin" animation, rotating the spinner 360 degrees over 1.2 seconds.
  • The linear timing function ensures a constant speed throughout the animation.
  • Inside the @keyframes rule, define the "spin" animation with 0% and 100% keyframes representing the starting and ending points of a full 360-degree rotation.
Jun 13, 2023 01:00 Back to Articles

Other Articles

10 common JavaScript interview questions that you might encounter !!!

In this article, we will discuss 10 JS questions that are commonly asked in interviews. These questions cover a range of JavaScript topics and are commonly asked in interviews to assess a candidate's understanding of the language. Make sure to practice and understand these concepts to perform well in JavaScript interviews.

1 year ago By Mitali Gupta
What is Agile Development ? What is Agile Development ?

Agile development is a software development approach that emphasizes flexibility, collaboration, and continuous delivery. It involves iterative development, continuous feedback, a collaborative approach, adaptability, and continuous improvement.

1 year ago By Mitali Gupta
Creating a Spinner Using Pure HTML and CSS Creating a Spinner Using Pure HTML and CSS

In this article, we will explore how to create a stylish spinner using pure HTML and CSS. The animated circle rotates indefinitely, offering visual feedback for ongoing processes on your web pages.

1 year ago By Mitali Gupta
How to identify Stack Questions? How to identify Stack Questions?

In this article, you will get clarity about how to find any given question that can be solved using stack.

1 year ago By Aniket Prajapati