CSS

Bouncing Ball Loader

HTML CSS to create a bouncing ball animation using keyframes

8/9/2022
0 views
bouncing-ball-loader.htmlHTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bouncing Ball Loader</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body { background-color: #292929; }

        section {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100vh;
        }

        div.loader {
            width: 120px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        div.loader .dot {
            width: 25px;
            height: 25px;
            background-color: #f5dc00;
            border-radius: 100%;
            margin: 0 3px;
            animation: loading 1s linear infinite;
            animation-delay: calc(0.1s * var(--i));
        }

        @keyframes loading {
            0% {
                transform: translateY(-20px);
            }

            25%, 75% {
                transform: translateY(0);
            }

            100% {
                transform: translateY(-20px);
            }
        }
    </style>
</head>
<body>
    <section>
        <div class="loader">
            <span class="dot" style="--i:3"></span>
            <span class="dot" style="--i:2"></span>
            <span class="dot" style="--i:1"></span>
            <span class="dot" style="--i:0"></span>
        </div>
    </section>
</body>
</html>
CSSHTMLPreloaderLoading AnimationBouncing Ball

Loading comments...

Related Examples

Understanding CSS Shadows: box-shadow vs drop-shadow
CSS

Understanding CSS Shadows: box-shadow vs drop-shadow