CSS3 How do I achieve text gradients? CSS3 three ways to implement text gradients (code)

Source: Internet
Author: User
Tags wrapper
This article brings you to the content is about CSS3 how to achieve text gradient? CSS3 realize the text gradient of three methods (code), there is a certain reference value, the need for friends can refer to, I hope to help you.

In the development process, the UI designer will often design some with the gradient text of the design, to our programmers, and our programmers, most of them are silently sigh, but the birth of CSS3, solve the front-end development process of a lot of problems, such as animation, masks and so on

1. What we want to achieve today is to use pure CSS to implement the gradient text, the following is the preview image:

2. Basic style:

. gradient-text{              Text-align:left;              text-indent:30px;              line-height:50px;              font-size:40px;              Font-weight:bolder;               position:relative;               }

3. The first method, using BACKGROUND-CLI, Text-fill-color:

. gradient-text-one{      background-image:-webkit-linear-gradient (bottom,red, #fd8403, yellow);     -webkit-background-clip:text;     -webkit-text-fill-color:transparent; }

4. The second method, using Mask-image:

. gradient-text-two{   color:red;}. gradient-text-two[data-content]::after{    content:attr (data-content);    Display:block;    Position:absolute;    Color:yellow;    left:0;    top:0;    Z-index:2;    -webkit-mask-image:-webkit-gradient (linear, 0 0, 0 bottom, from (yellow), to (RGBA (0, 0, 255, 0)));}

5. The third method, using LinearGradient, fill:

. gradient-text-three{    Fill:url (#SVGID_1_);    font-size:40px;    Font-weight:bolder;}
<svg viewboxs= "0 0" class= "Svgbox" >    <defs> <lineargradient id=        "svgid_1_" gradientunits = "Userspaceonuse" x1= "0" y1= "x2=" 0 "y2=" >            <stop  offset= "0" style= "stop-color:yellow"/>            <stop  offset= "0.5" style= "Stop-color: #fd8403"/>            <stop  offset= "1" style= "stop-color:red"/ >        </linearGradient>    </defs>    <text text-anchor= "Middle" class= "gradient-text-three "x=" 110px "y=" 30% "> Florescence </text></svg>

6. All the demo code:

<! DOCTYPE html>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.