css实现一个炫酷动画loading(一)


html

typescript 复制代码
   <div class="loader">
        <div class="circle">
            <div class="dot"></div>
            <div class="outline"></div>
        </div>
        <div class="circle">
            <div class="dot"></div>
            <div class="outline"></div>
        </div>
        <div class="circle">
            <div class="dot"></div>
            <div class="outline"></div>
        </div>
        <div class="circle">
            <div class="dot"></div>
            <div class="outline"></div>
        </div>
    </div>

css

typescript 复制代码
<style>
    body {
        background-color: #000;
    }
    .loader {
        margin-top: 200px;
        display: flex;
        justify-content: center;
        align-items: center;
        --color: hsl(0, 0%, 87%);
        --animation: 2s ease-in-out infinite;
    }

    .loader .circle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 20px;
        height: 20px;
        border: solid 2px var(--color);
        border-radius: 50%;
        margin: 0 10px;
        background-color: transparent;
        animation: circle-keys var(--animation);
    }

    .loader .circle .dot {
        position: absolute;
        transform: translate(-50%, -50%);
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background-color: var(--color);
        animation: dot-keys var(--animation);
    }

    .loader .circle .outline {
        position: absolute;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        border-radius: 50%;
        animation: outline-keys var(--animation);
    }

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

    .circle:nth-child(3) {
        animation-delay: 0.6s;
    }

    .circle:nth-child(4) {
        animation-delay: 0.9s;
    }

    .circle:nth-child(5) {
        animation-delay: 1.2s;
    }

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

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

    .circle:nth-child(4) .dot {
        animation-delay: 0.9s;
    }

    .circle:nth-child(5) .dot {
        animation-delay: 1.2s;
    }

    .circle:nth-child(1) .outline {
        animation-delay: 0.9s;
    }

    .circle:nth-child(2) .outline {
        animation-delay: 1.2s;
    }

    .circle:nth-child(3) .outline {
        animation-delay: 1.5s;
    }

    .circle:nth-child(4) .outline {
        animation-delay: 1.8s;
    }

    .circle:nth-child(5) .outline {
        animation-delay: 2.1s;
    }

    @keyframes circle-keys {
        0% {
            transform: scale(1);
            opacity: 1;
        }

        50% {
            transform: scale(1.5);
            opacity: 0.5;
        }

        100% {
            transform: scale(1);
            opacity: 1;
        }
    }

    @keyframes dot-keys {
        0% {
            transform: scale(1);
        }

        50% {
            transform: scale(0);
        }

        100% {
            transform: scale(1);
        }
    }

    @keyframes outline-keys {
        0% {
            transform: scale(0);
            outline: solid 20px var(--color);
            outline-offset: 0;
            opacity: 1;
        }

        100% {
            transform: scale(1);
            outline: solid 0 transparent;
            outline-offset: 20px;
            opacity: 0;
        }
    }
</style>
相关推荐
沉默璇年1 小时前
react中useMemo的使用场景
前端·react.js·前端框架
yqcoder1 小时前
reactflow 中 useNodesState 模块作用
开发语言·前端·javascript
2401_882727571 小时前
BY组态-低代码web可视化组件
前端·后端·物联网·低代码·数学建模·前端框架
SoaringHeart2 小时前
Flutter进阶:基于 MLKit 的 OCR 文字识别
前端·flutter
会发光的猪。2 小时前
css使用弹性盒,让每个子元素平均等分父元素的4/1大小
前端·javascript·vue.js
天下代码客2 小时前
【vue】vue中.sync修饰符如何使用--详细代码对比
前端·javascript·vue.js
猫爪笔记2 小时前
前端:HTML (学习笔记)【1】
前端·笔记·学习·html
前端李易安3 小时前
Webpack 热更新(HMR)详解:原理与实现
前端·webpack·node.js
红绿鲤鱼3 小时前
React-自定义Hook与逻辑共享
前端·react.js·前端框架
Domain-zhuo3 小时前
什么是JavaScript原型链?
开发语言·前端·javascript·jvm·ecmascript·原型模式