Sat Jul 30 2022

Floating Animated Background

CSS7100 views


Floating Animated Background

File Name: floating-animation-on-background.html

<!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>Background Animation</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        section {
            background-color: #1abc9c;
            width: 100%;
            height: 100vh;
            position: relative;
        }

        ul#shape {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
        }

        ul#shape li {
            position: absolute;
            display: block;
            list-style: none;
            width: 40px;
            height: 40px;
            background-color: rgba(255,255,255,0.4);
            bottom: -200px;

            animation: floating 25s infinite linear;

        }

        ul#shape li:nth-child(1) {
            width: 80px;
            height: 80px;
            left: 25%;
            animation-delay: 0.1s;
        }

        ul#shape li:nth-child(2) {
            width: 20px;
            height: 20px;
            left: 95%;
            animation-delay: 10s;
        }

        ul#shape li:nth-child(3) {
            width: 70px;
            height: 70px;
            left: 75%;
            animation-delay: 18s;
        }

        ul#shape li:nth-child(4) {
            width: 30px;
            height: 30px;
            left: 10%;
            animation-delay: 5s;
        }

        ul#shape li:nth-child(5) {
            width: 40px;
            height: 40px;
            left: 60%;
            animation-delay: 8s;
        }

        ul#shape li:nth-child(6) {
            width: 90px;
            height: 90px;
            left: 84%;
            animation-delay: 1s;
        }

        ul#shape li:nth-child(7) {
            width: 50px;
            height: 50px;
            left: 50%;
            animation-delay: 15s;
        }

        ul#shape li:nth-child(8) {
            width: 100px;
            height: 100px;
            left: 40%;
            animation-delay: 6s;
        }

        @keyframes floating {
            from {
                transform: translateY(0) rotate(0deg);
                opacity: 1;
                border-radius: 0;
            }

            to {
                transform: translateY(-1000px) rotate(720deg);
                opacity: 0;
                border-radius: 80%;
            }
        }
    </style>
</head>
<body>
    <section id="bg">
        <ul id="shape">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </section>
</body>
</html>

Result Screenshot(s)

Floating Animated BackgroundWorking Sample0

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.