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>
相关推荐
Python大数据分析@3 分钟前
通俗的讲,网络爬虫到底是什么?
前端·爬虫·网络爬虫
Lysun00124 分钟前
vue2的$el.querySelector在vue3中怎么写
前端·javascript·vue.js
jerry-8943 分钟前
Centos类型服务器等保测评整/etc/pam.d/system-auth
java·前端·github
小爬菜1 小时前
Django学习笔记(启动项目)-03
前端·笔记·python·学习·django
想要打 Acm 的小周同学呀1 小时前
前端Vue2项目使用md编辑器
前端·编辑器·vue2·markdown 语法
计算机-秋大田1 小时前
基于SSM的家庭记账本小程序设计与实现(LW+源码+讲解)
java·前端·后端·微信小程序·小程序·课程设计
海的预约2 小时前
VUE之路由Props、replace、编程式路由导航、重定向
前端·vue.js·智能路由器
西柚与蓝莓3 小时前
报错:{‘csrf_token‘: [‘The CSRF token is missing.‘]}
前端·flask
python算法(魔法师版)3 小时前
html,css,js的粒子效果
javascript·css·html
德迅云安全-小钱4 小时前
跨站脚本攻击(XSS)原理及防护方案
前端·网络·xss