
css属性中有一个background-clip,用于设置绘图的背景,它的值可以是content-box,padding-box,border-box,text,其中text就是把颜色绘制到文字上,还有一个属性是text-fill-color,它也是设置对象中文字的填充颜色,和color作用一样,它的优先级比color大,还有就是他的兼容性不太好,只适用于谷歌。
//字体颜色渐变
.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;
}
<p class="text">1234567</p>
//颜色渐变+动画效果 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; } } <p class="text">1234567</p>
上面是“css属性background-clip实现渐变颜色+动画效果”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2088.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

Paletton:一款专业在线配色工具,帮助设计师快速创建色彩搭配方案
AI Manga Translator:专为漫画爱好者设计的AI在线漫画翻译工具
来画AI:一家专注于动画和数字人创作的平台
涂鸦王国官方网址入口,一个国内的精英插画师社交网站
HunyuanCustom:支持文本、图像、音频、视频多模态输入的多模态定制视频生成框架
Animate & Create官网使用入口,美国顶级3D动画与创意视觉平台
一款免费开源的JavaScript文件上传组件—— Uppy
Dreemy AI:内置超20万个AI角色,支持用户即时对话、沉浸式互动