css中波浪动画从左到右的过渡

Rat*_*rai 4 html css

大家好,我正在尝试使用 svg 在 css 中制作波浪动画,大部分工作正常,但我确实有一个问题,一旦波浪到达终点,它会突然重新开始,区别在于清晰可见,我想让过渡平滑以获得更好的用户界面,以便对用户来说波浪似乎是无穷无尽的。

请检查下面的代码片段以了解我的问题谢谢

.wave {
  background: url(https://gist.githubusercontent.com/ratnabh/da8213a27700e0e1c2d1c81961070f6f/raw/3608a5072f4e392b852e5cc3c244841025b32c81/wave1.svg) repeat-x; 
  position: absolute;
  opacity:0.2;
  bottom: 0px;
  width: 2000px;
  height: 198px;
  animation: wave 2s cubic-bezier( 0.36, 0.45, 0.63, 0.53) infinite;
  transform: translate3d(0, 0, 0);
}

@keyframes wave {
  0% {
    margin-left: 0;
  }
  100% {
    margin-left: -1000px;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="wave"></div>
        
Run Code Online (Sandbox Code Playgroud)

Abh*_*dey 5

这可能会解决你的问题

正如您在图像中看到的,起点和终点的高度相同。

所以我将 div 的宽度增加到wave图像的两倍。并将div移动到图像的最末端,以1920px消除波动。

body{overflow:hidden;}
.wave {
  background: url(https://gist.githubusercontent.com/ratnabh/da8213a27700e0e1c2d1c81961070f6f/raw/3608a5072f4e392b852e5cc3c244841025b32c81/wave1.svg) repeat-x; 
  position: absolute;
  opacity:0.2;
  bottom: 0px;
  width: 3840px;
  height: 198px;
  animation: wave 4s linear infinite;
  transform: translate3d(0, 0, 0);
  
}

@keyframes wave {
  0% {
    margin-left: 0;
  }
  100% {
    margin-left: -1920px;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="wave"></div>
Run Code Online (Sandbox Code Playgroud)