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>
相关推荐
Smile_Gently2 小时前
前端:最简单封装nmp插件(组件)过程。
前端·javascript·vue.js·elementui·vue
luckycoke8 小时前
小程序立体轮播
前端·css·小程序
一 乐8 小时前
高校体育场管理系统系统|体育场管理系统小程序设计与实现(源码+数据库+文档)
前端·javascript·数据库·spring boot·高校体育馆系统
懒羊羊我小弟8 小时前
常用Webpack Loader汇总介绍
前端·webpack·node.js
祈澈菇凉9 小时前
ES6模块的异步加载是如何实现的?
前端·javascript·es6
我爱学习_zwj9 小时前
4.从零开始学会Vue--{{组件通信}}
前端·javascript·vue.js·笔记·前端框架
顾比魁9 小时前
XSS盲打:当攻击者“盲狙”管理员
前端·网络安全·xss
黑客老李9 小时前
新手小白如何挖掘cnvd通用漏洞之存储xss漏洞(利用xss钓鱼)
java·运维·服务器·前端·xss
晚风予星9 小时前
简记|LogicFlow自定义BPMN元素节点
前端
Json____10 小时前
使用html css js 开发一个 教育机构前端静态网站模板
前端·css·html·js·前端学习·企业站·教育机构网站