How to apply texture to text with a shadow

Miles Rose

I am trying to style some text to look like a paper cut-out by adding an image texture and a drop shadow.

I have applied an image texture to the text using CSS; however, when I try to add text-shadow the shadow appears in front of the text rather than behind it.

@import url(https://fonts.googleapis.com/css?family=Slackey);
.paperText { 
    font-family: 'Slackey', cursive;
    background:url('http://i.imgur.com/sEWJZF2.jpg'); 
    font-size:60px;
    text-align:center;
    color:transparent;
    -webkit-background-clip:text;
    text-shadow: 5px 5px 10px #000;
}
<h1 class="paperText"><HEAD>Texture</HEAD></h1>

How can I get the shadow to appear behind the text?

partypete25

I don't think it's possible to do that on the one element. What you can do is create another element to handle the text-shadow and then layer that behind the original.

.paperText:after {
  position:absolute;
  top:0;
  left:0;
  color:#fff;
  content:'Texture';
  z-index:-1;
  text-shadow: 5px 5px 10px #000; 
  text-align:left; 
}

https://jsfiddle.net/3tkm7gj7/1/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related