Make the text part of a div transparent

I need to find a way to view the image behind the div through the text in the div:

eg.

enter image description here

I have a font as a web font. Is this possible without having to replace the image?

+3


source to share


1 answer


One way to accomplish your spec using just CSS is to blend the two background images completely, thus creating the "transparent" effect you describe. Here's a fiddle: http://jsfiddle.net/v780v1Ln/ .

Note: paddings, etc. resize the element and affect the coordinates that should be set for background images.

HTML:



<div id = "wrapper">
    <h1><span>DRD</span></h1>
</div>

      

CSS

* {
    padding: 0;
    margin: 0;
}

html, body {
    height: 100%;
    background: #e2e2e2;
}

#wrapper {
    position: absolute;
    width: 70%;
    height: 50%;
    top: 25%;
    left: 15%;
    background: url(http://i58.tinypic.com/2vdieso.jpg)
                no-repeat
                0 0/500px 362px;
}

#wrapper > h1 {
    background-color: #fff;
    text-align: center;
    position: absolute;
    padding: 0 55px 0 25px;
    top: 25px;
    left: 25px;
}

#wrapper > h1 > span {
    font: bold 70px/1 Sans-Serif;
    text-transform: uppercase;
    background: url(http://i58.tinypic.com/2vdieso.jpg)
                no-repeat
                -45px -25px/500px 362px;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

      

+3


source







All Articles