Home  >  Article  >  Web Front-end  >  How to use CSS3 gradients to achieve text color gradients?

How to use CSS3 gradients to achieve text color gradients?

不言
不言Original
2018-11-08 16:06:213117browse

In recent web design, I feel that there are more and more designs containing gradients. This time, we will introduce how to apply CSS3 gradients to text, and introduce how to fill images onto text.

Apply a color gradient on text

This is a gradient color that is set to the background color of the text. Currently supported browsers are Google Chrome, Safari, and Opera. (Recommended Course: CSS3 Video Tutorial)

HTML

<h1>你好,PHP中文网</h1>

HTML lists the text to be gradient as is.

CSS

h1{
  color: #ACB6E5;
  background: -webkit-linear-gradient(90deg, #ACB6E5, #86FDE8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

The effect is as follows:

How to use CSS3 gradients to achieve text color gradients?

You can also change the position of the color by specifying the angle of the gradient to make it a bit rough. texture.

CSS

h1{
  color: #FF7C00;
  background: -webkit-linear-gradient(top, #FFB76B 0%, #FFA73D 50%, #FF7C00 51%, #FF7F04 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

The effect is as follows:

How to use CSS3 gradients to achieve text color gradients?

Use images to fill the text color

In addition to setting the gradient color as the background color, you can also use an image to set the font color.

Let’s use this picture to set the color for the background

How to use CSS3 gradients to achieve text color gradients?

The code is as follows:





	
	


<h1>你好,PHP中文网</h1>

The effect is as follows:

How to use CSS3 gradients to achieve text color gradients?

The above is the detailed content of How to use CSS3 gradients to achieve text color gradients?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn