常见渐变字体效果

如图:

代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=`, initial-scale=1.0">
    <title>渐变字体</title>
    <style>
        .box {
            display: flex;
            flex-direction: column;
            gap: 60px;
            justify-content: left;
        }

        .box>div {

            font-size: 30px;
            font-weight: 700;
            line-height: 30px;
        }

        /* 单色边框渐变字体  */
        .font {
            display: inline-block;
            font-size: 30px;
            font-weight: 700;
            position: relative;
            text-align: left;
            font-family: 'Roboto Condensed', sans-serif;

        }

        .font .stroke {
            -webkit-text-stroke: 10px #000;
        }

        .font .text {
            color: #13abe7;

            position: absolute;
            left: 0;
            top: 0;
            margin: auto;
        }

        .font .text::before {
            content: attr(text);
            position: absolute;
            left: 0;
            top: 0;

            color: #12df0b;
            -webkit-mask: linear-gradient(91.34deg, transparent, black);

        }

        /* 不带边框渐变字体 */
        .noborder {
            display: inline-block;

            background: linear-gradient(91.34deg, #3dfff3 19.81%, #9483ff 76.46%);
            background-size: contain;
            color: transparent;
            background-clip: text;
            /*兼容safari*/
            -webkit-background-clip: text;


        }

        /* 渐变边框渐变字体 */
        .bordergradient .text {
            -webkit-background-clip: text;
            background-clip: text;


            background-image: linear-gradient(180deg, #f30cf3 0%, #05beec 100%);
            color: #FE58E2;
            -webkit-text-stroke-color: transparent;
            -webkit-text-stroke-width: 8px;
            margin-bottom: 0;
            display: block;
            text-wrap: nowrap;


        }

        .bordergradient .text::before {
            content: attr(text);
            position: absolute;

            color: #FFB455;
            -webkit-mask: linear-gradient(180deg, transparent, black);
        }

        /* 渐变边框单色字体 */

        .text-gradient2 .text {
            -webkit-background-clip: text;
            background-clip: text;
            background-image: -webkit-gradient(linear, left top, left bottom, from(#FE58E2), to(#FFB455));
            background-image: linear-gradient(180deg, #FE58E2 0%, #FFB455 100%);
            color: #FFFFFF;
            -webkit-text-stroke-color: transparent;
            -webkit-text-stroke-width: 8px;
            margin-bottom: 0;
            text-align: center;
            text-wrap: nowrap;


        }
    </style>
</head>

<body>
    <div class="box">
        <!-- 单色边框渐变字体 -->
        <div class="font ">
            <span class="stroke">Hello world!</span>
            <span class="text " text="Hello world!">Hello world!</span>
        </div>
        <!-- 不带边框渐变字体 -->

        <div class="noborder">
            Hello world!
        </div>

        <!-- 渐变边框渐变字体 -->
        <div class=" bordergradient">
            <span class="text " text="Hello world!">Hello world!</span>
        </div>
        <!-- 渐变边框单色字体 -->
        <div class="text-gradient2">
            <span class="text " text="Hello world!">Hello world!</span>
        </div>
    </div>


</body>

</html>

  • 8
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值