The Wayback Machine - https://web.archive.org/web/20240118180808/https://www.geeksforgeeks.org/loading-text-animation-effect-using-css/
Open In App
Related Articles

Loading Text Animation Effect using CSS

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report


There are a lot of animations possible in CSS and today we will look at the loading text animation. The basic idea behind the working of this animation is the application of animation delay. Every alphabet is delayed by .1s so that each alphabet animates with a little delay and give the loading animation.

HTML Code: It is used to create the basic structure of the text loading animation. We will use <span> tag to display all alphabets in a linear fashion. The <span> tags are enclosed by <div> tag.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
          
    <title>Loading Text Animation using CSS</title>
</head>
  
<body>
    <div class="geeks">
        <span>G</span>
        <span>E</span>
        <span>E</span>
        <span>K</span>
        <span>S</span>
        <span>F</span>
        <span>O</span>
        <span>R</span>
        <span>G</span>
        <span>E</span>
        <span>E</span>
        <span>K</span>
        <span>S</span>
    </div>
</body>
  
</html>


CSS Code: The CSS property is used to apply animation effect. First, we apply animation to all the alphabets and then add some delay. The duration of delay can be adjusted according to the need. You can adjust the animation duration and keyframes to make the animation a little faster or slower.




<style>
    .geeks {
        height: 40px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }
  
    .geeks span {
        font-family: -apple-system, BlinkMacSystemFont,
            "Segoe UI", Roboto,Oxygen, Ubuntu, Cantarell,
            "Open Sans", "Helvetica Neue", sans-serif;
        font-size: 24px;
        color: green;
        display: inline-block;
        transition: all 0.5s;
        animation: animate 2s infinite;
    }
    .geeks span:nth-child(1) {
        animation-delay: 0.1s;
    }
    .geeks span:nth-child(2) {
        animation-delay: 0.2s;
    }
    .geeks span:nth-child(3) {
        animation-delay: 0.3s;
    }
    .geeks span:nth-child(4) {
        animation-delay: 0.4s;
    }
    .geeks span:nth-child(5) {
        animation-delay: 0.5s;
    }
    .geeks span:nth-child(6) {
        animation-delay: 0.6s;
    }
    .geeks span:nth-child(7) {
        animation-delay: 0.7s;
    }
    .geeks span:nth-child(8) {
        animation-delay: 0.8s;
    }
    .geeks span:nth-child(9) {
        animation-delay: 0.9s;
    }
    .geeks span:nth-child(10) {
        animation-delay: 1s;
    }
    .geeks span:nth-child(11) {
        animation-delay: 1.1s;
    }
    .geeks span:nth-child(12) {
        animation-delay: 1.2s;
    }
    .geeks span:nth-child(13) {
        animation-delay: 1.3s;
    }
  
    @keyframes animate {
        0% {
            color: green;
            transform: translateY(0);
            margin-left: 0;
        }
        25% {
            color: green;
            transform: translateY(-15px);
            margin-left: 10px;
        }
        100% {
            color: green;
            transform: translateY(0);
            margin-left: 0;
        }
    }    
</style>


Complete Code: In this section, we will combine both HTML and CSS code to design a Loading Text Animation effect using HTML and CSS.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
          
    <title>Loading Text Animation using CSS</title>
      
    <style>
        .geeks {
            height: 40px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translateX(-50%) translateY(-50%);
        }
      
        .geeks span {
            font-family: -apple-system, BlinkMacSystemFont,
                "Segoe UI", Roboto,Oxygen, Ubuntu, Cantarell,
                "Open Sans", "Helvetica Neue", sans-serif;
            font-size: 24px;
            color: green;
            display: inline-block;
            transition: all 0.5s;
            animation: animate 2s infinite;
        }
        .geeks span:nth-child(1) {
            animation-delay: 0.1s;
        }
        .geeks span:nth-child(2) {
            animation-delay: 0.2s;
        }
        .geeks span:nth-child(3) {
            animation-delay: 0.3s;
        }
        .geeks span:nth-child(4) {
            animation-delay: 0.4s;
        }
        .geeks span:nth-child(5) {
            animation-delay: 0.5s;
        }
        .geeks span:nth-child(6) {
            animation-delay: 0.6s;
        }
        .geeks span:nth-child(7) {
            animation-delay: 0.7s;
        }
        .geeks span:nth-child(8) {
            animation-delay: 0.8s;
        }
        .geeks span:nth-child(9) {
            animation-delay: 0.9s;
        }
        .geeks span:nth-child(10) {
            animation-delay: 1s;
        }
        .geeks span:nth-child(11) {
            animation-delay: 1.1s;
        }
        .geeks span:nth-child(12) {
            animation-delay: 1.2s;
        }
        .geeks span:nth-child(13) {
            animation-delay: 1.3s;
        }
      
        @keyframes animate {
            0% {
                color: green;
                transform: translateY(0);
                margin-left: 0;
            }
            25% {
                color: green;
                transform: translateY(-15px);
                margin-left: 10px;
            }
            100% {
                color: green;
                transform: translateY(0);
                margin-left: 0;
            }
        }    
    </style>
</head>
  
<body>
    <div class="geeks">
        <span>G</span>
        <span>E</span>
        <span>E</span>
        <span>K</span>
        <span>S</span>
        <span>F</span>
        <span>O</span>
        <span>R</span>
        <span>G</span>
        <span>E</span>
        <span>E</span>
        <span>K</span>
        <span>S</span>
    </div>
</body>
  
</html>


Output:


Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 27 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials