mpvue微信小程序动画_微信小程序加载动画:旋转方块

本文展示了如何使用mpvue在微信小程序中创建一个旋转方块的加载动画,包括wxml和wxss代码实现,并提供了详细的效果展示和动画原理说明。
摘要由CSDN通过智能技术生成

效果展示

435bcc42d659e14b2e21df32230a4a5f.gif

Demo代码

wxml

    <view class="loading-screen">
        <view class="loading">
            <view class="flour" >view>
            <view class="flour" >view>
            <view class="flour" >view>
            <view class="flour" >view>
        view>
    view>

wxss

page{
  margin: 0;
  padding: 0;
}

.loading-screen{
  width: 100%;
  height: 100vh;
  background-color: #2e2e2e;
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading{
  width: 80px;
  display: flex;
  flex-wrap: wrap;
  animation: rotate 3s linear infinite;
}

@keyframes rotate{
  to{
      transform: rotate(360deg);
  }
}

.loading .flour{
  width: 32px;
  height: 32px;
  background-color: #00cec9;
  margin: 4px;
  animation: scale 1.5s linear infinite;
}

@keyframes scale{
  50%{
      transform: scale(1.2);
  }
}

效果展示

bf4f4c3331ac4c397b21ecd6f08b4cec.gif

Demo代码

wxml

    <view class="loading-screen">
        <view class="loading">
            <view class="flour_1" >view>
            <view class="flour_2" >view>
            <view class="flour_3" >view>
            <view class="flour_4" >view>
        view>
    view>

wxss

page{
  margin: 0;
  padding: 0;
}

.loading-screen{
  width: 100%;
  height: 100vh;
  background-color: #2e2e2e;
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading{
  width: 80px;
  display: flex;
  flex-wrap: wrap;
  animation: rotate 4s linear infinite;
}

@keyframes rotate{
  to{
      transform: rotate(360deg);
  }
}

.loading .flour_1{
  width: 32px;
  height: 32px;
  background-color: #eb4d4b;
  margin: 4px;
  animation: scale 2s linear infinite;
}

.loading .flour_2{
  width: 32px;
  height: 32px;
  background-color: #2ecc71;
  margin: 4px;
  animation: scale 2s linear infinite;
}
.loading .flour_3{
  width: 32px;
  height: 32px;
  background-color: #00cec9;
  margin: 4px;
  animation: scale 2s linear infinite;
}
.loading .flour_4{
  width: 32px;
  height: 32px;
  background-color: #f1c40f;
  margin: 4px;
  animation: scale 2s linear infinite;
}
@keyframes scale{
  50%{
      transform: scale(1.2);
  }
}

Animation说明

属性描述
@keyframes规定动画
animation所有动画属性的简写属性,除了 animation-play-state 属性
animation-name规定 @keyframes 动画的名称
animation-duration规定动画完成一个周期所花费的秒或毫秒
animation-timing-function规定动画的速度曲线
animation-delay规定动画何时开始
animation-iteration-count规定动画被播放的次数
animation-direction规定动画是否在下一周期逆向地播放
animation-play-state规定动画是否正在运行或暂停
animation-fill-mode规定对象动画时间之外的状态

说明

Demo代码已同步至小程序

67ade171d23c78196ad0cae963989b7a.gif     

写留言|查看留言

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值