Space Background Animation

Home / Web Code Snippet / Space Background Animation

Space Background Animation


https://youtube.com/shorts/VdCmq1hBQzc?si=j7yYqxAc0eQl7wZ1

HTML CODE:-

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <title></title>
</head>
<body>
<div class="container">
    <i class="fa-solid fa-rocket"></i>
</div>
</body>
</html>

CSS CODE:-

body{
            padding: 0px;
            margin: 0px;
            width: 100%;
            min-height: 100vh;
            overflow: hidden;
            background-image: url("https://media.istockphoto.com/id/501655522/photo/star-field-at-night.jpg?s=612x612&w=0&k=20&c=-1cqc4KLNrDNJij4wDf-0jwXovhMxfrV1x_I24B-oKc=");
            background-size: cover;
            animation: animate 8s linear infinite;
        }
        @keyframes animate{
            0%{
                background-position: 0 0;
            }
               100%{
                background-position: 10% 80%;
                }
        }
        .container{
            position: absolute;
            top: 55%;
            left: 15%;
            text-align: center;
            width: 150px;
            height: 150px;
            pointer-events: none;
            line-height: 150px;
            border-radius: 50%;
            box-shadow: inset 0 0 55px rgba(255, 255, 255, .2);
            animation: animate1 5s linear infinite;
        }
        @keyframes animate1{
            0%{
                transform: translate(-20px,-20px);
            }
            25%{
                transform: translate(20px,0px);
            }
            50%{
                transform: translate(20px,-20px);
            }
            75%{
                transform: translate(20px,0px);
            }
            100%{
                transform: translate(-20px,-20px);
            }
        }
        .container::before{
            content: "";
            position: absolute;
            top: 70px;
            left: 30px;
            width: 20%;
            height: 40%;
            filter: blur(10px);
            background: yellow;
            box-shadow: 0px 0px 50px yellow;
            border-radius: 50%;
            transform: rotate(45deg);
            z-index: -1;
            animation: animate2 5s linear infinite;
        }
        @keyframes animate2{
            0%{
                background: yellow;
            }
            25%{
                background: orange;
            }
            50%{
                background:skyblue;
            }
            75%{
                background: greenyellow;
            }
            100%{
                background: yellow;
            }
        }
        .container i{
            color: white;
            font-size: 30px;
        }