How to Create Sliding Text Reveal Animation using HTML & CSS ?
In this article, we will implement sliding text reveal animation which can be used in personal portfolios, websites, and even in YouTube introduction videos to add an extra edge to our videos so that it looks more interesting and eye-catchy at first instance and the best part is that we will do that using just HTML and CSS.
Approach: The animation will begin with the appearance of the first text, for example, we are taking the word as “GEEKSFORGEEKS”, and then it will slide towards the left, and our second text that is: “A Computer Science Portal For Geeks” will reveal towards the right (If you’re still confused, what the animation is all about, you can quickly scroll to the end of the page and see the output, for better understanding).
We will be using different keyframes to divide our animation into different stages so that it works smoothly.
Keyframes hold what styles the element will have at certain times. The following keyframes are used:
- @keyframes appear: In this keyframe, we will deal with the way the first text appears.
- @keyframes slide: In this keyframe, we will try to move the text in a sliding manner.
- @keyframes reveal: In this keyframe, we will reveal our second text.
Below is the implementation of the above approach.
Example: In this example, we will be going to use the above-defined properties to create the animation.
Note: For other texts of different lengths the width and the font size of both the text should be changed accordingly.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.