Detailed explanation of the idea of ​​implementing dynamic effect of lyrics progress text color filling change using CSS3

Detailed explanation of the idea of ​​implementing dynamic effect of lyrics progress text color filling change using CSS3

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');
}

Note: The effect achieved by the above code is only supported by webkit browsers

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

Recommend

Let’s talk about the symbol data type in ES6 in detail

Table of contents Symbol Data Type The reason why...

Summary of Common Letters in Unicode

Most of the earliest computers could only use ASC...

Bootstrap 3.0 study notes buttons and drop-down menus

The previous article was a simple review of the B...

Detailed steps to configure MySQL remote connection under Alibaba Cloud

Preface As we all know, by default, the MySQL ins...

Detailed explanation of MySQL custom functions and stored procedures

Preface This article mainly introduces the releva...

HTML uses the title attribute to display text when the mouse hovers

Copy code The code is as follows: <a href=# ti...

Detailed tutorial on how to install mysql8.0 using Linux yum command

1. Do a good job of cleaning before installation ...

Getting Started Guide to MySQL Sharding

Preface Relational databases are more likely to b...

JavaScript to switch multiple pictures

This article shares the specific code of JavaScri...

Detailed explanation of js event delegation

1. Each function is an object and occupies memory...

Application of HTML and CSS in Flash

Application of HTML and CSS in Flash: I accidental...

Design Theory: Ten Tips for Content Presentation

<br /> Focusing on the three aspects of text...

How to test the maximum number of TCP connections in Linux

Preface There is a misunderstanding about the max...