text inner shadow

For a project I am working on right now I needed to create text that had an inner shadow. The look I wanted was that the text was almost stamped into the surface of the page.

After some searching and finding some hacks that sort of worked, I came across this great trick!

using the :before and :after pseudo-elements you can easily create this effect.

It might not work for every situation, but it did great for me.

view demo

here's what you need to know -

Your text needs to have a class, and a title tag with the same message. ( h tags or divs work best )

/* TEXT */

< h1 class="text" title="Hello World!">Hello World.< /h1>

/* CSS */

.text {
    font-size:7em;
    font-weight:bold;
    color:#000000;
    position:relative;
   
    /* OPTIONAL */
    padding:90px;

    letter-spacing:-4px;
    
}
.text:before, .text:after {
    content: attr(title);
    color: rgba(255,255,255,.1);
    position: absolute;
   
    /* OPTIONAL */
    padding:90px;

    letter-spacing:-4px;
}
.text:before {
    top: 1px;
    left: 1px;
}
.text:after {
    top: 2px;
    left: 2px;
}

 

comments