小程序波浪球动画

先看一下效果,波浪的大小会根据数值的变化而不断变化
在这里插入图片描述

html代码(这里只写和波浪球相关的代码)

<view class="charging-ball-container">
    <view class="wave-wrapper" style="bottom:{{percent}}%"></view>
    <view class="percent-txt">{{percent}}%</view>
</view>

css代码

.charging-ball{
  position: relative;
  align-items: center;
  width: 350rpx;
  height: 350rpx;
  border-radius: 50%;
  background-color: #12FFBE;
  overflow: hidden;
  border: 8rpx solid #c6ffed;
  z-index: 100;
}
.wave-wrapper {
  position: absolute;
  left: 50%;
  width: 700rpx;
  height: 700rpx;
  background-color: #fff;
  border-radius: 50%;
   /* 动画完成花费的时间 */
  animation-duration: 5s;
  animation-name: rotate;
  /* 无限次播放动画 */
  animation-iteration-count: infinite;
  /* 动画从头到尾的速度是相同的 */
  animation-timing-function: linear;
}
.percent-txt{
  position: absolute;
  z-index: 200;
  left: 35%;
  top: 40%;
  color: #fff;
  font-size: 76rpx;
  font-weight: 500;
}
/* 过渡动画 */
@keyframes rotate {
  0% {
    transform: translate(-50%, 0) rotateZ(0deg);
  }
  50% {
    transform: translate(-50%, -1%) rotateZ(180deg);
  }
  100% {
    transform: translate(-50%, 0) rotateZ(360deg);
  }
}

js代码

js中的代码很少,就是定义了一个百分比的数字

data: {
    orderId: 0,
    percent: 55
},
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值