A text-fill animation using CSS is a visual effect where the content of text gradually fills with a color, gradient, or pattern over time. This animation can create dynamic, eye-catching effects for headings or titles by adjusting properties like background-size, clip-path, or keyframe animations.
Approach:
- Position Text: Use absolute positioning to center the text vertically and horizontally on the page.
- Create Overlay: The ::before pseudo-element overlays the original text with a different color.
- Text Content: Use content: attr(data-text) to duplicate the original text for the overlay effect.
- Hidden Overlay: Initially, set the overlay's width to 0% for a hidden state.
- Reveal on Hover: Increase the overlay's width to 100% on hover using a smooth transition.
Example: Here we are following the above-explained approach.
Output:
👁 Image