2

I'm toying around with CSS animations for fun. My limited experience is getting in the way.

The script below transforms a circle to triangle to an square and reverses. The animation between circle and triangle however has a slight bug. I expect it has something to do with the border but I can't seem to fix it. (I have no background in programming..:))

Could someone give me a push in the right direction?

.triangle {
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-color: transparent;
  animation-name: testframe;
  animation-duration: 4s;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

@keyframes testframe {
/*circle*/
  0% {
    width: 100px;
    height: 100px;
    background-color: #6980fe;
    border-radius: 50%;
  }
/*trianle*/
  50% {
    width: 0;
    height: 0;
    border: 0 solid transparent;
    border-right-width: 50px;
    border-left-width: 50px;
    border-bottom: 100px solid #6980fe;
    background-color: transparent;
  }
/*square*/
  100% {
    width: 100px;
    height: 100px;
    background-color: #6980fe;
  }
}
1
  • If one of the answers below fixes your issue, you should accept it (click the check mark next to the appropriate answer). That does two things. It lets everyone know your issue has been resolved to your satisfaction, and it gives the person that helps you credit for the assist. See here for a full explanation. Commented Nov 9, 2018 at 14:00

1 Answer 1

1

for to fix this slight bug, you shoud to include this property in triangle animation:

"border-radius: 0;"

like this:

...

/*trianle*/
50% {
   width: 0;
   height: 0;
   border: 0 solid transparent;
   border-radius: 0;
   border-right-width: 50px;
   border-left-width: 50px;
   border-bottom: 100px solid #6980fe;
   background-color: transparent;
}

...

I hope help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.