html - 如何使我的无限线性动画流畅?
问题描述
当动画重置时,动画中会出现明显的中断。
这是我所拥有的:
@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>
我怎样才能让它光滑而不引人注目?
解决方案
看起来,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>
推荐阅读
- c++ - 如何在没有额外副本的情况下从 std::map 安全地“pop-front”?
- javascript - 自定义配置底部导航
- javascript - 如何使 HTML 网站具有交互性,以便当用户单击删除按钮时它会为所有用户更改,即使您重新加载也是如此?
- javascript - 如果vue仍然抛出错误,那么vue中props中的默认值的目的是什么?
- google-bigquery - 如何使用 BigQuery 在没有每个元素的情况下获取所有总和值?
- react-native - React-Native-Audio-Toolkit 准备失败
- python - 在 Python 中计算指数分布的 lambda 参数的置信区间
- operating-system - 使用基址和边界时地址空间大小和“边界”有什么区别?
- python - 将三个列表合并为一个列表
- java - 通过使用像 'List
',我怎样才能得到它的类,就像classForName("List “)?