I have a product configurator on my website. The user can write a word on a clothe and a text appears on the product image.
I want to style this text to look like an embroidery. So i put a text shadow, the text color changes in function of the product color, but now, i want to put a "filter" over the color.
Constraint: i just have access to the CSS.
here's a fiddle i did:
#text
{
font-size:90px;
text-align:center;
font-family:'petit_formal_script';
-webkit-font-smoothing:antialiased;
text-shadow: 2px 2px 2px black;
color:lightblue;
}
#text:after
{
content:'';
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
background-image:url('http://hdwbin.com/wp-content/uploads/2014/11/red-background.jpg');
-webkit-background-clip:text;
-moz-background-clip:text;
-webkit-text-fill-color:transparent;
}
http://jsfiddle.net/u2to713t/
Thanks in advance.
Changing Text Background Color in CSS. To change the background color of the inline text, go to the <head> section. Simply add the appropriate CSS selector and define the color and background-color property with the values you want.
You can use background-color: rgba(0,0,0,0); The a is for alpha , it sets the opacity. But the background-color: transparent; is the way to go.
The “background-clip: text” is supported in all main browsers with the Webkit prefix, it allows a background image to be clipped by a text element. In this guide we will look at examples using the background-clip property and the different values you can use.
If that class has a background-color of blue, and you want your <div> to have a red background instead, try to change the color from blue to red in the class itself. You could also create a new CSS class that defined a background-color property with a value of red and let your <div> reference that class.
I Finally did it.. The result is not what i expected but it works. Here's the final fiddle for the one who will try one day to do the same thing:
http://jsfiddle.net/u2to713t/13/
#text
{
font-size:90px;
text-align:center;
font-family:'petit_formal_script';
-webkit-font-smoothing:antialiased;
text-shadow: 1px 2px 3px #474747;
color:lightblue;
}
#text:before
{
content: attr(data-text);
position:absolute;
left:-1px;
top:7px;
right:0;
bottom:0;
opacity:1.0;
z-index: 1;
color:transparent;
text-shadow:0px 0px 0px;
background:url("http://image.noelshack.com/fichiers/2015/20/1431421588-brodrwhite.png");
-webkit-background-clip:text;
-moz-background-clip:text;
background-clip:text;
}
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