Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent text which ignores the first background

I don't know if this is possible in css, I am sure that it can be done in js but i don't know how...

I have a div with a background and a text that is in another div with another background. What I would like is the text to be transparent and have the first-background as the text background. I don't know if this is clear so I've created a fiddle for this:

<div id="first-background">
    <div id="second-background">
        <h1>This text should be transparent and have the first-background as its background and ignore the second background.</h1>
    </div>
</div>

http://jsfiddle.net/K2Ytv/

like image 450
emcee22 Avatar asked Jun 26 '13 06:06

emcee22


People also ask

How do you make a background color transparent in CSS but not text?

The percentage of opacity is calculated as Opacity% = Opacity * 100 To set the opacity only to the background and not the text inside it. It can be set by using the RGBA color values instead of the opacity property because using the opacity property can make the text inside it fully transparent element.

How do I make text transparent on an image in HTML?

For having a simple, transparent text on an image, you need to have your image or background image in a <div> element, and the content block in another <div>. Then, use the CSS opacity property to set a transparent image or text. The opacity property is used to adjust the transparency of a text or photo.

How do I make a text box transparent in HTML?

input[type=text] { background: transparent; border: none; } background-color:rgba(0,0,0,0);


1 Answers

This technique is called clipping mask.

You can refer to DEMOS AND TUTORIALS ON CLIPPING MASK to achieve what you want.

like image 88
Nitesh Avatar answered Sep 22 '22 13:09

Nitesh