Wed Mar 08 2023

Loading text with linear gradient

CSS183 views

File Name: happy-holi.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>Happy Holi</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=Secular+One&display=swap" rel="stylesheet">
    <style>
        :root {
            --pink: #ea00ff;
            --yellow: #cbf800;
            --green: #00ff25;
            --red: #ff0000;
        }

        * {
            margin: 0;
            padding: 0;
            font-family: 'Secular One', sans-serif;
        }

        body {
            background-color: #282828;
        }

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

        h1 {
            font-size: 80px;
            font-weight: 700;
            color: #363636;
            position: relative;
        }

        h1::before {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            content: attr(data-text);
            background-image: linear-gradient(30deg, var(--pink), var(--yellow), var(--green), var(--red));
            -webkit-background-clip: text;
            color: transparent;
            animation: loading 6s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }   

        @keyframes loading {
            0% { height: 0;}
            20% { height: 45%;}
            80% { height: 75%;}
            90% { height: 85%;}
            100% { height: 100%;}
        }
        
    </style>
</head>
<body>
    <section>
        <h1 data-text="Happy Holi">Happy Holi</h1>
    </section>
</body>
</html>

Result Screenshot(s)

Loading text with linear gradientWorking 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.