假设我有以下代码:
<span>Hello world!</span>
以及以下 CSS:
span{
color:red;
}
有什么方法可以将 red
更改为图像吗?喜欢 url(images/text-bg.png);
?我想在我的文本上放置一个纹理,并决定将文本“颜色”设置为图像,但我不确定这是否可以使用 CSS 完成。
最佳答案
有可能,看看这支笔
https://codepen.io/feferonka/pen/eoWLZp
在文本的父级上使用它:
background-image: url(url);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
关于html - 为字体颜色设置背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7261680/