美文网首页
用css画一个文字渐变

用css画一个文字渐变

作者: HelenYin | 来源:发表于2019-11-21 15:27 被阅读0次

方法一: mask-image

<div class="regular-title" data-text="道路运输">道路运输</div>
.regular-title {
    position: relative;
    color: #07ebf1;
}
.regular-title[data-text]::after {
    content: attr(data-text);
    color: #0070a2;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    mask-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgba(0, 0, 255, 0)), color-stop(0.5, #ff0000), to(rgba(0, 0, 255, 0)));
    -webkit-mask-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgba(0, 0, 255, 0)), color-stop(0.5, #ff0000), to(rgba(0, 0, 255, 0)));
    text-stroke: 1px #02b2d2;
    -webkit-text-stroke: 1px #02b2d2;
}

方法二: text-fill-color + background-clip

    <div class="background-clip">
        蔡文姬蔡文姬蔡文姬
    </div>
.background-clip {
            width: 677px;
            height: 388px;
            background: -webkit-gradient(linear, 0 0, 0 bottom, from(#07ebf1), color-stop(0.5, #0070a2), to(#07ebf1));
            font-size: 60px;
            font-weight: 600;
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

相关文章

网友评论

      本文标题:用css画一个文字渐变

      本文链接:https://www.haomeiwen.com/subject/ybdtwctx.html