Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an element transparent to clicks but still visible?

Tags:

html

css

I'm interested in putting an inset box shadow on something like an iframe. While the strategy of overlaying a div over the iframe gives the expected visual display, the div subsequently blocks clicks on the iframe itself.

Sample: http://jsfiddle.net/YqXPg/

So is there a way to pull off the inset shadow as a "framing" effect?

like image 720
Steven Avatar asked Jun 10 '11 00:06

Steven


People also ask

How do I make a div transparent in click?

You can solve this problem using the “none” value of the CSS pointer-events property. In the case of using this value, the element will not react to the pointer-events. With the help of the CSS background property put your transparent background.

How do I make part of a div transparent?

First, we create a <div> element (class="background") with a background image, and a border. Then we create another <div> (class="transbox") inside the first <div>. The <div class="transbox"> have a background color, and a border - the div is transparent.

How do you make an element transparent in CSS?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).


1 Answers

Yes, there's pointer-events: none.

See: http://jsfiddle.net/YqXPg/3/

A version that makes the overlay more obvious: http://jsfiddle.net/YqXPg/4/

Note that this property doesn't work with IE, but if I remember correctly, IE will allow you to click through the transparent parts of the overlay div anyway.

like image 183
thirtydot Avatar answered Sep 21 '22 12:09

thirtydot