两种风格的纯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>

页面效果:

相关推荐
格调UI成品4 分钟前
元宇宙工厂前端新形态:Three.js与WebGL实现3D产线交互的轻量化之路
前端·javascript·webgl
gnip15 分钟前
微前端框架选型
前端·javascript
芒果12525 分钟前
【转载文章】ECharts-GL 实现世界级、国家级、省市级 3D 地图
前端
一只小风华~35 分钟前
JavaScript:数组常用操作方法的总结表格
前端·javascript·数据结构·vue.js·算法
前端老鹰39 分钟前
JavaScript Array.prototype.some ():数组判断的 “快捷侦探”
前端·javascript
张元清40 分钟前
揭秘JS事件循环:一道字节跳动面试题带你深入理解async/await、Promise与RAF
前端·react.js·面试
KenXu44 分钟前
F2C-Chrome插件-Figma免费的DevMode来了!
前端
北海几经夏1 小时前
React组件中的this指向问题
前端·react.js
passer9811 小时前
列表项切换时同步到可视区域
前端
FogLetter1 小时前
移动端适配的终极奥义:从lib-flexible到postcss-pxtorem的全方位指南
前端·postcss