Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize text Color gradient by css3

Shulou Source: shulou.com Published: 2022-06-01 07:37:10 10月26日 Update

This article is about how css3 implements text color gradients. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The first method of css3 text color gradient is to realize the dynamic color gradient of css text through the animation attributes of css3.

Text color gradient

H3 {

Height:60px

Color:#f35626

Background:coral

Background-image:-webkit-linear-gradient (45degpence.f35626pr. Feab3a)

-webkit-background-clip:text

-webkit-text-fill-color:transparent

-webkit-animation:hue6sinfinitelinear

}

@-webkit-keyframeshue {

From {

-webkit-filter:hue-rotate (0deg)

}

To {

-webkit-filter:hue-rotate (- 360deg)

}

}

The second method of css3 text color gradient is to realize the static effect of text color gradient through mask-image attribute.

Text color gradient

. text-gradient {

Display:inline-block

Font-family:' Microsoft Yahei'

Font-size:5em

Position:relative

}

. text-gradient [data-text]:: after {

Content:attr (data-text)

Color:green

Position:absolute

Left:0

Z-index:2

-webkit-mask-image:-webkit-gradient (linear,00,0bottom,from (# ff0000), to (rgba))

}

As can be seen from the CSS code, the implementation of the effect, in addition to "content content generation technology", mainly uses the mask-image attribute.

The third method of css3 text color gradient is to achieve the static effect of text color gradient through the background-clip+text-fill-color attribute.

Text color gradient effect

. text-gradient {

Display:inline-block

Color:green

Font-size:5em

Font-family:' Microsoft Yahei'

Background-image:-webkit-gradient (linear,00,0bottom,from (rgba), to (rgba))

-webkit-background-clip:text

-webkit-text-fill-color:transparent

}

Thank you for reading! On "css3 how to achieve text color gradient" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Tags: Text color attributes effects content methods more articles static Microsoft good practical code dynamic animation technology articles see knowledge reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB Shulou Information Apple Linux