微信小程序ColorUl组件中波浪动画的实现

ColorUI组件里的波浪动画怎么做的,其实很简单。先来看看效果

动画.gif

原理是三张图片通过动画滚动实现的
wxml代码:

  <view class="waveWrapper waveAnimation">
    <view class="waveWrapperInner bgTop">
      <view class="wave waveTop" style="background-image:url('http://image.weilanwl.com/img/wave-top.png')"></view>
    </view>
    <view class="waveWrapperInner bgMiddle">
      <view class="wave waveMiddle" style="background-image:url('http://image.weilanwl.com/img/wave-mid.png')"></view>
    </view>
    <view class="waveWrapperInner bgBottom">
      <view class="wave waveBottom" style="background-image:url('http://image.weilanwl.com/img/wave-bot.png')"></view>
    </view>
  </view>

图片只能是网络图片

wxss代码:

@keyframes move_wave {
  0% {
    transform: translateX(0) translateZ(0) scaleY(1);
  }

  50% {
    transform: translateX(-25%) translateZ(0) scaleY(1);
  }

  100% {
    transform: translateX(-50%) translateZ(0) scaleY(1);
  }
}

.waveWrapper {
  overflow: hidden;
  position: relative;
  height: 50rpx;
  width: 100%;
  background: #39b54a;
}

.waveWrapperInner {
  position: absolute;
  width: 100%;
  overflow: hidden;
  height: 100%;
  bottom: -1px;
}
.bgTop {
  z-index: 15;
  opacity: 0.5;
  height: 24px;
}

.bgMiddle {
  z-index: 10;
  opacity: 0.75;
  height: 19px;
}

.bgBottom {
  z-index: 5;
  height: 14px;
}

.wave {
  position: absolute;
  left: 0;
  width: 2160px;
  height: 100%;
  background-repeat: repeat no-repeat;
  background-position: 0 bottom;
  transform-origin: center bottom;
}
.wave image {
  width: 100%;
  position: absolute;
  bottom: 0;
}

.waveTop {
  background-size: 540px 25px;
}

.waveAnimation .waveTop {
  animation: move_wave 30s linear infinite;
}

.waveMiddle {
  background-size: 1080px 20px;
}

.waveAnimation .waveMiddle {
  animation: move_wave 24s linear infinite;
}

.waveBottom {
  background-size: 540px 15px;
}

.waveAnimation .waveBottom {
  animation: move_wave 12s linear infinite;
}

基本上就已经实现了动画,改成相应底色就可以了。

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值