Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing mouse clicks through an overlaying element <div>

Is it possible to pass mouse clicks through an overlaying element:

<div style="background: url('img/rain.png'); z-index: 100; width: 100%; height: 100%; top: 0; bottom: 0; left: 0; right: 0;"></div>

down to underlaying elements (paragraphs, images, links, etc)?


Or worded another way:

Is there any way of creating a purely aesthetic overlay/layer in HTML, CSS and/or JavaScript?

like image 669
LeslieOA Avatar asked Nov 15 '09 13:11

LeslieOA


People also ask

How do I allow click through Div?

Just use the pointer-events:none css property to allow click events to go through the element.

What is use of pointer events in CSS?

The pointer-events property allows for control over how HTML elements respond to mouse/touch events – including CSS hover/active states, click/tap events in Javascript, and whether or not the cursor is visible.

Which among the event handler attributes is triggered when the mouse moves on top of an element?

The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves.


1 Answers

This can be solved using CSS:

div { pointer-events:none; }

Supported by IE 11+, Chrome, Firefox, Safari and Opera.

More details: https://developer.mozilla.org/en-US/docs/CSS/pointer-events

like image 187
sandstrom Avatar answered Oct 15 '22 05:10

sandstrom