Need help with an animated circle

{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body{
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #102626
}

.container{
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-box-reflect: below 1px linear-gradient(#0001, #0004)
}

.container .loader{
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: #0d2323
  animation: animate 2s linear infinite;
}
@keyframes animate{
  0%{
    transform: rotate(0deg);
  }
  100%{
    transform: rotate(360deg);
  }
}
.container .loader::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(to top, transparent, rgba(0,255,249,0.4));
  background-size: 100px 100px;
  background repeat: no-repeat;
  border-top-left-radius: 100px;
  border-bottom-left-radius: 100px;
}
.container .loader::after{
  content: '';
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: #00fff9;
  border-radius: 50%;
  z-index: 10;
  box-shadow: 0 0 10px #00fff9,
              0 0 20px #00fff9,
              0 0 30px #00fff9,
              0 0 40px #00fff9,
              0 0 50px #00fff9,
              0 0 60px #00fff9,
              0 0 70px #00fff9,
              0 0 80px #00fff9,
              0 0 90px #00fff9,
              0 0 100px #00fff9; 
}

.container .loader span {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  background: #102626;
  border-radius: 50%;
}

I’m trying to make an animated circle with a highlighted thing that goes around. I’m not quite sure what I’ve done wrong and have been trying to figure it out for the past day. I think its the “before” and “after” statements that aren’t working correctly. Any suggestions?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Alright, I’ll keep that in mind for next time. Thank you!

  1. You are missing the semicolon ; after background: #0d2323 in the .container .loader selector.

  2. You are missing the dash, for background repeat: no-repeat;, it should be background-repeat: no-repeat; (in the .container .loader::before selector).

  3. You are misssing position: absolute on the .container .loader::after selector.

Not really sure what it is supposed to look like so that makes it a little hard to know if there is anything else wrong.

Thank you! It worked!

Here’s the finished product, lmk how it looks!

2 Likes

Happy to help, it’s a cool looking spinner. I like it.

I did miss one more thing. You need a star * in front of the first selector. That should be a universal selector.

 * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}