Text Reveal Animation

<!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>Text Reveal Animation</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> 
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 'Lobster', cursive;
        }
   

        body { background-color: #292929; }

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

        h1 {
            font-size: 40px;
            font-weight: normal;
            color: #fff;
        }

        h1 span {
            position: relative;
            overflow: hidden;
            display: block;
            list-style: 2;
            margin: 2px 0;
        }

        h1 span::before {
            position: absolute;
            content: '';
            top: 0;
            right: 0;
            width: 100%;
            height: 100%;
            background-color: #292929;
            transform: translateX(0);
            animation: showBefore 2s cubic-bezier(0.77, 0,0.18,1) forwards;
        }

        h1 span::after {
            position: absolute;
            content: '';
            top: 0;
            right: 0;
            width: 100%;
            height: 100%;
            background-color: #fff;
            transform: translateX(-101%);
            animation: showAfter 2s cubic-bezier(0.77, 0,0.18,1) forwards;
        }

        h1 span:nth-of-type(1)::before,
        h1 span:nth-of-type(1)::after {
            animation-delay: 1s;
        }

        h1 span:nth-of-type(2)::before,
        h1 span:nth-of-type(2)::after {
            animation-delay: 1.5 s;
        }

        @keyframes showBefore {
            0% { transform: translateX(0); }
            100% { transform: translateX(200%); }
        }

        @keyframes showAfter {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(101%); }
        }
        
    </style>
</head>
<body>
    <section>
       <h1>
            <span>Website without visitors is like</span>
            <span>a ship lost in the horizon.</span>
       </h1>
    </section>
</body>
</html>
                                Copy Code
                            

Result Screenshot(s)

Text Reveal AnimationWorking Sample0