如何使我的无限线性动画更加流畅?

3
当动画重置时,动画会出现明显的中断。以下是我的内容:

@keyframes AnimationName {
  0% {
    background-position: 100% 0%
  }
  100% {
    background-position: 0% 0%
  }
}

.myanimation {
  width: 50px;
  height: 150px;
  background: repeating-linear-gradient(-45deg, #43ABC9, #43ABC9 7px, #369ebc 7px, #369ebc 14px);
  animation: AnimationName 2s linear infinite;
  background-size: 200% 200%;
}
<div class="myanimation"></div>

如何使其顺畅且不可察觉?

相关:https://dev59.com/sbLma4cB1Zd3GeqPWipP / https://dev59.com/hVUK5IYBdhLWcg3wgQHd#51734530 - Temani Afif
1个回答

5

看起来background-size: 200% 200%;background-position: 100% 0%;不太兼容。如果将background-position: 200% 0%;设为一定,它就会顺利运行。

通过将动画设置为两倍长,我们可以确保它看起来仍然以相同的速度移动。

@keyframes AnimationName {
  0% {
    background-position: 200% 0%
  }
  100% {
    background-position: 0% 0%
  }
}

.myanimation {
  width: 50px;
  height: 150px;
  background: repeating-linear-gradient(-45deg, #43ABC9, #43ABC9 7px, #369ebc 7px, #369ebc 14px);
  animation: AnimationName 4s linear infinite;
  background-size: 200% 200%;
}
<div class="myanimation"></div>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接