Say I have the following code:
<span>Hello world!</span>
And the following CSS:
span{
color:red;
}
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.
it is possible, take a look at this pen here
https://codepen.io/feferonka/pen/eoWLZp
Use this on parent of text:
background-image: url(url);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With