css3实现loading动画

在这里插入图片描述

<div class="loading">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>
.loading {
  width: 76px;
  height: 60px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: space-between;
  align-items: center;

  span {
    display: inline-block;
    width: 8px;
    height: 100%;
    background: rgba(40, 89, 247, 0.5);
    border-radius: 20px;
    -webkit-animation: actionLoad 1s ease infinite;
    animation: actionLoad 1s ease infinite;

    &:last-child {
      margin-right: 0;
    }

    &:nth-child(2) {
      -webkit-animation-delay: 0.3s;
      animation-delay: 0.3s;
    }
    &:nth-child(3) {
      -webkit-animation-delay: 0.6s;
      animation-delay: 0.6s;
    }
    &:nth-child(4) {
      -webkit-animation-delay: 0.9s;
      animation-delay: 0.9s;
    }
    &:nth-child(5) {
      -webkit-animation-delay: 1.2s;
      animation-delay: 1.2s;
    }
  }

  @keyframes actionLoad {
    0%, 100% {
      height: 60%;
      background: rgba(40, 89, 247, 0.5);
    }
    50% {
      height: 100%;
      margin: -15px 0;
      background: rgba(40, 89, 247, 0.8);
    }
  }

语法:
animation:name duration timing-function delay iteration-count direction fill-mode play-state

参数说明:
name:@keyframes后面的名称
duration :多少秒或毫秒完成动画
timing-function:动画将如何完成一个周期
delay: 动画在启动前的延迟间隔
iteration-count: 动画的播放次数
direction: 是否应该轮流反向播放动画
fill-mode: 当动画不播放时(当动画完成时,或当动画有一个延迟未开始播放时),要应用到元素的样式
play-state: 动画是否正在运行或已暂停

timing-function可选参数
在这里插入图片描述
iteration-count可选参数在这里插入图片描述
direction可选参数在这里插入图片描述
fill-mode可选参数在这里插入图片描述
play-state可选参数在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值