1

Hello I've created simple infinite animation using css, but there are a simple problem that I need the animation is loop for ever smoothly.

.rotate{
    width:200px;
    height:200px;
    margin:50px auto;
    background-color:#00e95a;
    animation-name:rotate;
    animation-duration:1s;
    animation-iteration-count:infinite;
    animation-fill-mode:both;
}
@keyframes rotate {
    from {
        -moz-transform: rotate(0);
        -ms-transform: rotate(0);
        -o-transform: rotate(0);
        -webkit-transform: rotate(0);
        transform: rotate(0);
    }

    to {
        -moz-transform: rotate(-360deg);
        -ms-transform: rotate(-360deg);
        -o-transform: rotate(-360deg);
        -webkit-transform: rotate(-360deg);
        transform: rotate(-360deg);
    }
}
    <div class="rotate">

    </div>

0

2 Answers 2

4

Just add animation-timing-function: linear;.

Note: The problem was caused by the default timing state, which is ease.

.rotate {
  width: 200px;
  height: 200px;
  margin: 50px auto;
  background-color: #00e95a;
  animation-name: rotate;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-fill-mode: both;
  animation-timing-function: linear;
}

@keyframes rotate {
  from {
    -moz-transform: rotate(0);
    -ms-transform: rotate(0);
    -o-transform: rotate(0);
    -webkit-transform: rotate(0);
    transform: rotate(0);
  }
  to {
    -moz-transform: rotate(-360deg);
    -ms-transform: rotate(-360deg);
    -o-transform: rotate(-360deg);
    -webkit-transform: rotate(-360deg);
    transform: rotate(-360deg);
  }
}
<div class="rotate"></div>

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

1 Comment

Aww...beat me to it!
0

As @Kind user has mentioned you should hard reset animation-timing-function to linear, because the intial value of animation-timing-function is ease.

reference: https://developer.mozilla.org/en/docs/Web/CSS/animation-timing-function

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.