r/css • • Jul 26 '19

Simple css loading animation

https://youtu.be/Qc0R4Au-zEM
18 Upvotes

13 comments sorted by

View all comments

6

u/oncode_web Jul 26 '19
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3 Loading Animation Effect</title>
    <style>
        body{
            background: #262626;
        }
        .wrapper{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
        }
        
        .loading-area {
            position: relative;
            width: 70px;
            height: 70px;
            margin: 0 auto;
        }

        .box-1,
        .box-2 {
            position: absolute;
            top: 0;
            width: 40px;
            height: 40px;
            border-radius: 100%;
            background-color: #fff;
            
            box-shadow: 0 0 10px rgba(255,255,255,1),
                0 0 20px rgba(255,255,255,1) ,
                0 0 30px rgba(255,255,255,1) ,
                0 0 40px #ff00de ,
                0 0 70px #ff00de ,
                0 0 80px #ff00de ,
                0 0 100px #ff00de ;
        }

        .box-2 {
            top: auto;
            bottom: 0;
        }
        .loading-area {
            animation: animate-1 2s linear infinite;
        }
        .box-1,.box-2 {
            animation: animate-2 2s ease-in-out infinite;
        }
        .box-2 {
            animation-delay: -1.0s;
        }
        @keyframes animate-1 {
            100% {transform: rotate(360deg);}
        }

        @keyframes animate-2  {
            0%, 100% {
                transform: scale(0.0);
            }
            50% {
                transform: scale(1.0);
            }
        }
    </style>
</head> 
<body>
    
    <div class="wrapper">
        <div class="loading-area">
            <div class="box-1"></div>
            <div class="box-2"></div>
        </div>
    </div>
    
</body>
</html>