Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for the child of a div set to pointer-events: none to have pointer events?

Is it possible for the child of a div set to pointer-events: none to have pointer events?

I need the div that holds another div to allow pointer events to pass through, but for the div itself to still have events.

Is this possible?

like image 205
fancy Avatar asked Aug 12 '12 07:08

fancy


People also ask

What does pointer event none do?

In addition to indicating that the element is not the target of pointer events, the value none instructs the pointer event to go "through" the element and target whatever is "underneath" that element instead.

What is the default pointer events?

Default Pointer Events on an element corresponds to the CSS pointer events property. It controls whether or not an element will "pass through" clicks to elements that are underneath it (that is, elements that have a smaller z-index). For example, in the following canvas an image sits over a button element.

What are pointer events?

Pointer events are DOM events that are fired for a pointing device. They are designed to create a single DOM event model to handle pointing input devices such as a mouse, pen/stylus or touch (such as one or more fingers). The pointer is a hardware-agnostic device that can target a specific set of screen coordinates.

Does Safari support pointer events?

CSS pointer-events (for HTML) is Fully Supported on Safari 12, which means that any user who'd be accessing your page through Safari 12 can see it perfectly.


1 Answers

Yes, it's possible, and you basically just described how. Disable it for the parent and enable it for the child.

pointer-events is supported in almost every browser, including IE11

Please note that pointer-events: all is for SVG only.

For HTML, only auto and none are supported values.

.parent {   pointer-events: none; }  .child {   pointer-events: auto; }
<div class="parent">   <a href="#">Parent</a>   <div class="child">     <a href="#">Child</a>   </div> </div>

Demo: http://jsfiddle.net/4gQkT/

like image 92
Brandon Avatar answered Sep 20 '22 18:09

Brandon