CSS3实现动画加载效果

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>加载效果</title>
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
  	<!-- 弹跳加载动画 -->
    <div class="bouncing-loader">
      <div class="bouncing-loader-item"></div>
      <div class="bouncing-loader-item"></div>
      <div class="bouncing-loader-item"></div>
    </div>

	<!-- 旋转加载动画 -->
    <div class="spin-loading">
      <div class="loading"></div>
    </div>

	<!-- 点点点加载动画 -->
    <span class="dot">正在加载中<span class="dotted"></span></span>
  </body>
</html>
/* style.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  display: flex;
}
/* 弹跳加载效果 */
.bouncing-loader,
.spin-loading,
.dot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 150px;
  border: 1px solid #efefef;
  margin: 3rem;
}
.bouncing-loader-item {
  width: 16px;
  height: 16px;
  margin: 3rem 0.2rem;
  background-color: #0b16f1;
  border-radius: 50%;
  animation: bouncingLoader 0.6s infinite alternate;
}
.bouncing-loader-item:nth-child(2) {
  animation-delay: 0.2s;
}
.bouncing-loader-item:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes bouncingLoader {
  to {
    opacity: 0.1;
    transform: translate3d(0, -10px, 0);
  }
}

/* 旋转动画效果 */
.spin-loading .loading {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 100%;
  /* 锥形渐变 */
  background-image: conic-gradient(#0b16f1, 30%, #fff);
  /* 使用蒙版将中间变为透明 */
  -webkit-mask-image: radial-gradient(closest-side, transparent 80%, black 80%);
  /* 开启动画 */
  animation: spin 1s linear infinite reverse;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
/* ...动画效果 */
.dotted {
  display: inline-block;
  width: 20px;
}
.dotted::after {
  content: '';
  animation: dotted 2s infinite;
}
@keyframes dotted {
  0% {
    content: '...';
  }
  25% {
    content: '';
  }
  50% {
    content: '.';
  }
  75% {
    content: '..';
  }
  100% {
    content: '...';
  }
}

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员禅心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值