DEV Community

Cover image for Pure CSS Spinner
Amy Oulton
Amy Oulton

Posted on • Edited on

1 1

Pure CSS Spinner

I use a simple stock image and some vanilla CSS to create a simple spinner.

Spinner Gif

For this spinner I got this simple spinner of Pixabay (thanks gorkhs).

Rainbow Spinner

We start with just a very simple structure in our html.

<div class="spinner">
  <img src="./rainbow.png" class="img"/>
</div>
Enter fullscreen mode Exit fullscreen mode

Tip: Make sure you include the correct path and name to your image.

After some general styling, we do the spinner action using CSS keyframes. For the speed I chose, I went with this:

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

Want to see the full tutorial? Watch the YouTube video below or watch in on CodeCast to get access to all the code in the Player.

Be sure to follow me on CodeCast for more of my tutorials!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay