Skip to content

Instantly share code, notes, and snippets.

@DykiSA
Last active May 8, 2022 05:42
Show Gist options
  • Save DykiSA/0041a14d8c6bd9ba6a5ce49da29c44f9 to your computer and use it in GitHub Desktop.
Save DykiSA/0041a14d8c6bd9ba6a5ce49da29c44f9 to your computer and use it in GitHub Desktop.
Experiment - Spiral animation with CSS

This is my experiment when learning a @keyframe feature of CSS3

The preview is shown in the video here.

<!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>Spinner</title>
    <style>
        body {
            background-color: black;
        }
        .spin {
            width: 100vh;
            height: 100vh;
            position: relative;
            display: inline-block;
        }
        .spin div {
            position: absolute;
            border-radius: 50%;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }
        .spin div:nth-child(1) {
            animation: animate-spin 2.3s 1s infinite normal both;
            background-color: rgba(10, 158, 207, 0.8);
        }
        .spin div:nth-child(2) {
            background-color: rgba(207, 17, 10, .8);
            animation: animate-spin 2.3s 1.3s infinite normal none;
        }
        .spin div:nth-child(3) {
            background-color: rgba(0, 255, 26, 0.8);
            animation: animate-spin 2.3s 1.7s infinite normal both;
        }
        @keyframes animate-spin {
            0% {
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
            }
            80% {
                top: 30%;
                right: 30%;
                bottom: 30%;
                left: 30%;
                opacity: .3;
            }
        }
    </style>
</head>
<body>
    <div class="spin">
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment