如何使用css实现一个加载动画

如何使用css实现一个加载动画 有四个点 初始化为同一个颜色 每个阶段 不同的透明度 刷新也不会影响初始化

javascript 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
<div class="loading-container">
  <div class="loading-dot dot1"></div>
  <div class="loading-dot dot2"></div>
  <div class="loading-dot dot3"></div>
  <div class="loading-dot dot4"></div>
</div>
</body>
<style>

    /*加载动画开始*/
    .loading-container {
        padding: 5px 0;
        position: relative;
    }

    .loading-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        margin: 0 3px;
        background: #327eff;
        animation: loading 3s  infinite;
        float: left;
    }

    .dot1 {
        animation-delay: -1.5s;
    }

    .dot2 {
        animation-delay: -1s;
    }

    .dot3 {
        animation-delay: -0.5s;
    }

    .dot4 {
        animation-delay: 0s;
    }

    @keyframes loading {
        0% {
            opacity: 0.25;
        }
        50% {
            opacity:1;
        }

        100% {
            opacity: 0.25;
        }
    }
    /*加载动画结束*/
</style>
</html>
相关推荐
xiaofeichaichai6 小时前
Webpack
前端·webpack·node.js
问心无愧05136 小时前
ctf show web入门111
android·前端·笔记
唐某人丶6 小时前
模型越来越强,我们还需要 Agent 工程吗?—— 从价值重估到 Harness 实践
前端·agent·ai编程
智码看视界6 小时前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
JS菌7 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
excel8 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia3118 小时前
https连接传输流程
前端·面试
徐小夕8 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab8 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器