从右向左滑动背景图片,然后从左向右滑动

时间:2018-08-04 07:18:14

标签: css

我有从CSS调用的此代码,该代码从右向左滑动。在从右向左播放动画之后,如何将其向后滑动?

-webkit-animation: slide 5s linear infinite;
//like to slide back right after same speed and position

@-webkit-keyframes slide {
  from {
    background-position: -60px, -20px;
  }
  to {
    background-position: -170px, -20px;
  }
}

1 个答案:

答案 0 :(得分:0)

替代替代

bashOperator
div {
  animation: slide 5s linear infinite;
  background-image: url(https://via.placeholder.com/50x50);
  width: 120px;
  height: 120px;
}

@keyframes slide {
  0% {
    background-position: -60px, -20px;
  }
  50% {
    background-position: -170px, -200px;
  }
  100% {
    background-position: -60px, -20px;
  }
}