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>
相关推荐
abc800211703428 分钟前
前端Bug 修复手册
前端·bug
Best_Liu~31 分钟前
el-table实现固定列,及解决固定列导致部分滚动条无法拖动的问题
前端·javascript·vue.js
_斯洛伐克1 小时前
下降npm版本
前端·vue.js
苏十八2 小时前
前端进阶:Vue.js
前端·javascript·vue.js·前端框架·npm·node.js·ecmascript
st紫月3 小时前
用MySQL+node+vue做一个学生信息管理系统(四):制作增加、删除、修改的组件和对应的路由
前端·vue.js·mysql
乐容4 小时前
vue3使用pinia中的actions,需要调用接口的话
前端·javascript·vue.js
似水明俊德4 小时前
ASP.NET Core Blazor 5:Blazor表单和数据
java·前端·javascript·html·asp.net
至天5 小时前
UniApp 中 Web/H5 正确使用反向代理解决跨域问题
前端·uni-app·vue3·vue2·vite·反向代理
与墨学长5 小时前
Rust破界:前端革新与Vite重构的深度透视(中)
开发语言·前端·rust·前端框架·wasm
H-J-L6 小时前
Web基础与HTTP协议
前端·http·php