CSS简单实用的加载动画、骨架屏有效果图

效果图

.wxml

复制代码
<!-- 骨架屏 -->
<view wx:for="{{skeleton}}" wx:key="index" class="container center" style="--w:{{item.w}}rpx;--h:{{item.h}}rpx" />
<!-- 3D转圈 -->
<view class="arco-loading center">
  <view wx:for="{{5}}" wx:key="index" class="arco-loading-item" />
</view>
<!-- 旋转 -->
<view class="half-circle" />

.wxss

复制代码
page{ text-align: center; }
.center{ margin: 0 auto 100rpx; }
/* 骨架屏 */
.container{
  width: var(--w);
  height: var(--h);
  background: linear-gradient(90deg,#F2F3F5 25%,#E5E6EB 37%,#F2F3F5 63%);
  background-size: 400% 100%;
  animation:skeleton 1.5s cubic-bezier(0,0,1,1) infinite;
}
@keyframes skeleton {
  from{ background-position:100% 50%; }
  to{ background-position: 0 50%; }
}
/* 加载 */
.arco-loading{
  position: relative;
  width: 102rpx;
  height: 16rpx;
  transform-style: preserve-3d;
  perspective: 400rpx;
}
.arco-loading-item{
  position: absolute;
  top: 0;
  left: 50%;
  width: 16rpx;
  height: 16rpx;
  border-radius: 50%;
  background: #165DFF;
  transform: translate(-50%) scale(0);
  animation: arco 2s cubic-bezier(0,0,1,1) infinite forwards;
}
.arco-loading-item:nth-child(2) {
  background-color: #306FFF;
  animation-delay: .4s
}
.arco-loading-item:nth-child(3) {
  background-color: #1D4DD2;
  animation-delay: .8s
}
.arco-loading-item:nth-child(4) {
  background-color: #466ACB;
  animation-delay: 1.2s
}
.arco-loading-item:nth-child(5) {
  background-color: #5D7CCB;
  animation-delay: 1.6s
}
@keyframes arco{
  0% {
    transform: translate3D(-48%,0,-2rpx) scale(0.5)
  }
  22%{
    transform: translate3D(-280%,0,0) scale(1.25)
  }
  44%{
    transform: translate3D(-48%,0,2rpx) scale(2)
  }
  47%{
    transform: translateZ(2rpx) scale(2)
  }
  50% {
      transform: translate3D(48%,0,2rpx) scale(2)
  }
  72%{
    transform: translate3D(280%,0,0) scale(1.25)
  }
  94%{
    transform: translate3D(48%,0,-2rpx) scale(0.5)
  }
  97% {
    transform: translateZ(-2rpx) scale(0.5)
  }
}
/* 圆 */
.half-circle {
  width: 70rpx;
  height: 70rpx;
  border: 2px solid transparent;
  border-top-color:red;
  border-right-color:red;
  margin: 0 auto;
  border-radius:50%;
  animation: turn linear infinite 1.5s;
}
@keyframes turn{
  from{ transform: rotate(-360deg); }
  to{ transform: rotate(360deg); }
}

.js

复制代码
Page({
  data: {
    skeleton:[
      {w:100,h:100},
      {w:500,h:100},
      {w:300,h:60},
    ]
  },
})

遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
计算机程序设计小李同学1 分钟前
婚纱摄影集成管理系统小程序
java·vue.js·spring boot·后端·微信小程序·小程序
ashcn20015 分钟前
水滴按钮解析
前端·javascript·css
Java陈序员3 小时前
告别手写礼簿!一款开源免费的电子红白喜事礼簿系统!
javascript·css·html
winfredzhang6 小时前
从零构建:基于 Node.js 的全栈视频资料管理系统开发实录
css·node.js·html·音视频·js·收藏,搜索,缩略图
计算机徐师兄7 小时前
Java基于微信小程序的食堂线上预约点餐系统【附源码、文档说明】
java·微信小程序·食堂线上预约点餐系统小程序·食堂线上预约点餐微信小程序·java食堂线上预约点餐小程序·食堂线上预约点餐小程序·食堂线上预约点餐系统微信小程序
加个鸡腿儿1 天前
经验分享2:SSR 项目中响应式组件的闪动陷阱与修复实践
前端·css·架构
毕设源码-邱学长1 天前
【开题答辩全过程】以 基于微信小程序的松辽律所咨询系统的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
华仔啊1 天前
写 CSS 用 px?这 3 个单位能让页面自动适配屏幕
前端·css
菩提小狗1 天前
Sqli-Labs Less-3 靶场完整解题流程解析-豆包生成
前端·css·less
计算机毕设指导61 天前
基于微信小程序的钓鱼论坛系统【源码文末联系】
java·spring boot·mysql·微信小程序·小程序·tomcat·maven