This CSS code snippet helps you to create a text color change animation on a webpage. It uses the CSS @keyframes
rule to create the animation. The animation cycles through a series of keyframes, each of which specifies a different color for the text. The animation
property is then applied to the text element in the HTML code.
You can use this animation in your web/app project to add a touch of visual interest to your web pages. It can also be used to create a more dynamic and engaging user experience.
How to Create Text Color Change Animation in CSS
1. First of all, add the Google Fonts CDN link to your HTML header to access the Lobster font used in the animation. (Optional)
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet">
2. Now, add the following HTML code within your document. Place it where you want the animated text to appear on your website. Adjust the class and content as needed.
<div class="text-animation"> <p>Color <span class="change"></span></p> </div>
3. Apply styling to the text animation container and text elements using the following CSS code. Adjust the animation duration, colors, and content in the keyframes to suit your preferences.
.text-animation{ background: linear-gradient(to right, #e0eafc, #cfdef3); padding: 150px; } .text-animation p{ text-align: center; font-weight: bold; font-size: 2.9em; font-family: 'Lobster', cursive; } .change{ color: #9c27b0; } .change:after{ content: ""; animation: change 15s linear infinite; } @keyframes change{ 0%{ content: "Red"; color: red; } 10%{ content: "Yellow"; color: yellow; } 20%{ content: "Pink"; color: pink; } 30%{ content: "Black"; color: black; } 40%{ content: "Violet"; color: #ee82ee; } 50%{ content: "Orange"; color: orange; } 60%{ content: "Green"; color: green; } 70%{ content: "Dark Magenta"; color: #8b008b; } 80%{ content: "Purple"; color: #800080; } 90%{ content: "Indigo"; color: #4b0082; } 100%{ content: "Lime Green"; color: #32cd32; } }
That’s all! hopefully, you have successfully created a text color change animation on your website. If you have any questions or suggestions, feel free to comment below.
Similar Code Snippets:
I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences.
I truly enjoy what I’m doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.