设置背景图像的字体颜色? [英] Set background image for font color?

查看:138
本文介绍了设置背景图像的字体颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有以下代码:

<span>Hello world!</span>

和以下CSS:

span{
color:red;
}

有什么办法可以改变 / code>到图像?像 url(images / text-bg.png); ?我想在我的文本上添加一个纹理,并决定我只是使文字颜色的图像,但我不知道这是否可以用CSS。

Is there any way I can change the red to an image? Like url(images/text-bg.png);? I want to put a texture on my text and decided that I would just make the text "color" an image, but I'm not sure if this can be done with CSS.

推荐答案

是的,可以使用svg,你可以将< svg> 嵌入一个< div> ; < div> 之后的 $ 和背景图片,然后将z-index应用于< div> 。您可以使用矢量应用程序(如插画)按照您想要的方式创建svg。

Yes it's possible using svg , you can embed <svg> over one <div> and background image over another <div>, later apply z-index to <div>. You can use Vector applications like illustrator to create the svg the way you want.

<html>
<head>
<title>Untitled Document</title>
<style>
html
 {
    background-image:url('lauch.jpg');
    background-repeat:no-repeat;
    background-position:center;
    padding-top:200px;
 }
</style>
</head>
<body>

<div align="center">
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="140px" height="80px" viewBox="0 0 76.25 39.167" enable-background="new 0 0 76.25 39.167" xml:space="preserve">
<text transform="matrix(1 0 0 1 5.9336 30.417)" fill="none" stroke="red" stroke-width="0.25" stroke-miterlimit="10" font-family="'Tahoma'" font-size="36">Text</text>
</div>
</body>
</html>

这篇关于设置背景图像的字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆