两种风格的纯CSS3加载动画

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>加载动画</title>
    <style>
      .loader {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #3498db;
        animation: spin 1s linear infinite;
        margin: 0 auto;
      }

      @keyframes spin {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
      .spin {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 50px;
        width: 200px;
        height: 200px;
        border: 1px solid #999;
      }
      .spin span {
        margin-top: 5px;
      }
      .container {
        display: flex;
      }

      .dots {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 200px;
        height: 200px;
        margin: 50px;
        border: 1px solid #999;
      }
      
     
      .dot {
        width: 10px;
        height: 10px;
        background-color: #ccc;
        border-radius: 50%;
        margin: 0 3px;
        opacity: 0.4;
        animation: loading 1.2s infinite;
      }

      .dot:nth-child(1) {
        animation-delay: 0.1s;
      }

      .dot:nth-child(2) {
        animation-delay: 0.3s;
      }

      .dot:nth-child(3) {
        animation-delay: 0.5s;
      }

      @keyframes loading {
        0% {
          transform: scale(1);
          opacity: 0.4;
        }
        50% {
          opacity: 1;
          transform: scale(1.2);
        }
        100% {
          opacity: 0.4;
          transform: scale(1);
        }
      }
    </style>
  </head>
  <body>
    <div class="container">
      <!-- 第一种动画 -->
      <div class="spin">
        <div class="loader"></div>
        <span>加载中...</span>
      </div>

      <!-- 第二种动画 -->
      <div class="dots">
        <span class="dot"></span>
        <span class="dot"></span>
        <span class="dot"></span>
      </div>
    </div>
  </body>
</html>

页面效果:

相关推荐
vortex53 分钟前
解决 Kali 中 Firefox 下载语言包和插件速度慢的问题:配置国内镜像加速
前端·firefox·腾讯云
修仙的人6 分钟前
Rust + WebAssembly 实战!别再听说,学会使用!
前端·rust
maxine8 分钟前
JS Entry和 HTML Entry
前端
用户633107761236611 分钟前
Who is a Promise?
前端
比老马还六1 小时前
Blockly元组积木开发
前端
笨笨狗吞噬者1 小时前
【uniapp】小程序体积优化,JSON文件压缩
前端·微信小程序·uni-app
西洼工作室1 小时前
浏览器事件循环与内存管理可视化
前端·javascript·css·css3
xier1234561 小时前
高性能和高灵活度的react表格组件
前端
你打不到我呢1 小时前
nestjs入门:上手数据库与prisma
前端
多啦C梦a1 小时前
React 实战:从 setInterval 到 useInterval,一次搞懂定时器 Hook(还能暂停!)
前端·javascript·react.js