放慢背景动画CSS?

时间:2019-03-11 22:53:56

标签: html css html5

如何放慢此动画的速度并使它在所有浏览器中更流畅?有什么办法吗?

@keyframes animatedBackground {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  }
}
#animate-area {
  width: 200px;
  height: 200px;
  background-image: url(https://github.githubassets.com/images/modules/open_graph/github-mark.png);
  background-position: 0px 0px;
  background-repeat: repeat-x;
  animation: animatedBackground 10s linear infinite alternate;
}
<div id="animate-area"></div>

1 个答案:

答案 0 :(得分:0)

只需延长animation的持续时间。

以下内容将其从10s更改为30s

@keyframes animatedBackground {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  }
}
#animate-area {
  width: 200px;
  height: 200px;
  background-image: url(https://github.githubassets.com/images/modules/open_graph/github-mark.png);
  background-position: 0px 0px;
  background-repeat: repeat-x;
  animation: animatedBackground 30s linear infinite alternate;
}
<div id="animate-area"></div>