When playing music, the lyrics will gradually fill in color as the song progresses. The color does not change word by word, but rather changes horizontally pixel by pixel from left to right. In other words, the left and right sides of a word will appear to be different colors. This effect can be achieved through CSS3. Implementation ideas: 1. Background fills a background color and the color to be changed 2. -webkit-background-clip:text; cuts out the background of the text, which means the empty text 3. -webkit-text-fill-color:transparent; Make the cutout text transparent so that the background color can be seen through the cutout shape. At this time, the background color is the color of the font. 4. background-size:0 100%; Set the background width to 0, and then change the background width through the channel to achieve the text color reading effect. HTML code: <div style="padding:15% 35%; text-align:center;"> <span class="text">Fill text color from left to right</span> </div> CSS code: @keyframes scan { 0% { background-size:0 100%; } 100% { background-size:100% 100%; } } .text { background:#7e7e7e -webkit-linear-gradient(left, #fff, #fff) no-repeat 0 0; -webkit-text-fill-color:transparent; -webkit-background-clip:text; background-size:0 100%; } .load { background-size:100% 100%; animation: scan 5s linear; } jQuery code: window.onload = function(){ $('.text').addClass('load'); }
Summarize This concludes this article on how to use CSS3 to achieve dynamic effects of changing text color fill in lyrics progress. For more relevant CSS3 text color filling content, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Vue imports excel table, and automatically downloads the data that failed to import
>>: How to underline the a tag and change the color before and after clicking
Table of contents The first method: When the MySQ...
The difference between relative and absolute in H...
If you don’t understand what I wrote, there may b...
In fact, XHTML 1.0 is divided into two types (thr...
Let’s not waste any more time and get straight to...
I have always wanted to learn about caching. Afte...
In the Linux environment, you want to check wheth...
CSS Selectors Setting style on the html tag can s...
Table of contents plan Install Dependencies Intro...
I have found a lot of online resources on this pro...
<iframe src=”test.jsp” width=”100″ height=”50″...
This article records the specific method of insta...
1. Introduction Earlier we talked about the front...
Preface When it comes to database transactions, a...
1. Overview The Promise object is a specification...