Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pure CSS drawing circle animation

I wrote a pure css drawing circle animation, but there's a little white space between the two half circles during the animation. (When the animation ends, they gone.)

Can anyone please tell me why does this happened?

My HTML:

.circle__box {
  width: 200px;
  height: 200px;
  margin: 50px auto;
  position: relative;
}

.circle__wrapper {
  width: 100px;
  height: 200px;
  position: absolute;
  top: 0;
  overflow: hidden;
}

.circle__wrapper--right {
  right: 0;
}

.circle__wrapper--left {
  left: 0;
}

.circle__whole {
  width: 160px;
  height: 160px;
  border: 20px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  transform: rotate(-135deg);
}

.circle__right {
  border-top: 20px solid teal;
  border-right: 20px solid teal;
  right: 0;
  animation: circleRight 5s linear forwards;
}

.circle__left {
  border-bottom: 20px solid teal;
  border-left: 20px solid teal;
  left: 0;
  animation: circleLeft 5s linear forwards;
}

@keyframes circleRight {
  0% {
    transform: rotate(-135deg);
  }
  50%,
  100% {
    transform: rotate(45deg);
  }
}

@keyframes circleLeft {
  0%,
  50% {
    transform: rotate(-135deg);
  }
  100% {
    -webkit-transform: rotate(45deg);
  }
}
<div class="circle__box">
  <div class="circle__wrapper circle__wrapper--right">
    <div class="circle__whole circle__right"></div>
  </div>
  <div class="circle__wrapper circle__wrapper--left">
    <div class="circle__whole circle__left"></div>
  </div>
</div>

My complete code goes here. Thank you.

like image 415
Nicole Avatar asked Nov 16 '18 06:11

Nicole


1 Answers

Here it is, please check. It was because of you gave .circle-left and .circle-right left:0; and right:0; respectively, change it to left:1px; and right:1px; and you're done...

.circle__box {
  width: 200px;
  height: 200px;
  margin: 50px auto;
  position: relative;
}

.circle__wrapper {
  width: 100px;
  height: 200px;
  position: absolute;
  top: 0;
  overflow: hidden;
}

.circle__wrapper--right {
  right: 0;
}

.circle__wrapper--left {
  left: 0;
}

.circle__whole {
  width: 160px;
  height: 160px;
  border: 20px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  transform: rotate(-135deg);
}

.circle__right {
  border-top: 20px solid teal;
  border-right: 20px solid teal;
  right: 1px;
  animation: circleRight 5s linear forwards;
}

.circle__left {
  border-bottom: 20px solid teal;
  border-left: 20px solid teal;
  left: 1px;
  animation: circleLeft 5s linear forwards;
}

@keyframes circleRight {
  0% {
    transform: rotate(-135deg);
  }
  50%,
  100% {
    transform: rotate(45deg);
  }
}

@keyframes circleLeft {
  0%,
  50% {
    transform: rotate(-135deg);
  }
  100% {
    -webkit-transform: rotate(45deg);
  }
}
<div class="circle__box">
  <div class="circle__wrapper circle__wrapper--right">
    <div class="circle__whole circle__right"></div>
  </div>
  <div class="circle__wrapper circle__wrapper--left">
    <div class="circle__whole circle__left"></div>
  </div>
</div>
like image 87
ElusiveCoder Avatar answered Sep 23 '22 21:09

ElusiveCoder