css字体特效

css属性中有一个background-clip,用于设置绘图的背景,它的值可以是content-box,padding-box,border-box,text,其中text就是把颜色绘制到文字上,还有一个属性是text-fill-color,它也是设置对象中文字的填充颜色,和color作用一样,它的优先级比color大,还有就是他的兼容性不太好,只适用于谷歌。靠这两个属性我们就可以设置好看的字体

<style>
.text{-webkit-background-clip: text;
    background-clip: text;
    background-image:linear-gradient(rgb(255,255,0),rgb(0,255,255));
    font-size: 20px;
    width:120px;
     -webkit-text-fill-color: transparent; 
}
</style>
<body>
    <p class="text">1234567</p>
</body>

就是这样,再配合动画可以做出更好的效果

<style>
.text{-webkit-background-clip: text;
    width: 200%;
    background-clip: text;
    background-image:linear-gradient(-45deg,rgb(255,255,0),rgb(0,255,255));
    font-size: 20px;
    width:120px;
    animation: shine 2s infinite;
     background-blend-mode: hard-light; 
     background-size: 200%; 
     color: white;
     -webkit-text-fill-color: transparent; 
}
@keyframes shine {
    from {
        background-position: 100%;
    }
    to {
        background-position: 0;
    }
}
</style>
<body>
<p class='text'>123456</p>
</body>

background-blend-mode是背景层颜色的混合模式,hard-height是高亮,这样子字体颜色就会从左到右变换

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值