在本文中,我将向您展示几种使用 css 获取渐变文本的方法(以及一些不使用 css 的方法)。您可能已经熟悉其中一种方法。
方法 1、2 和 3 的 html
sub to axorax on yt!
登录后复制
方法 – 1(css)
h1 { background: -webkit-linear-gradient(#e28bfc, #8bb8fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
登录后复制
方法 – 2(css)
h1 { background: linear-gradient(#e28bfc, #8bb8fc); background-clip: text; color: transparent;}
登录后复制
方法 – 3(css 剪辑路径)
h1 { position: relative; display: inline-block;}h1::before { content: "sub to axorax on yt!"; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(#e28bfc, #8bb8fc); -webkit-background-clip: text; color: transparent; clip-path: text;}
登录后复制
方法 – 4 (svg)
gradient text
登录后复制
方法 – 5(html 画布)
const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.font = '3rem sans-serif'; const gradient = ctx.createLinearGradient(0, 0, canvas.width, 0); gradient.addColorStop(0, '#e28bfc'); gradient.addColorStop(1, '#8bb8fc'); ctx.fillStyle = gradient; ctx.fillText('Sub to Axorax on YT!', 10, 100);
登录后复制
希望您找到有用的东西!
以上就是方法中为您的网站提供渐变文本的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2672583.html