Pointer-Events
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.
While the
pointer-events
property takes eleven possible values, all but three of them are reserved for use with SVG. The three valid values for any HTML element are:none
prevents all click, state and cursor options on the specified HTML elementauto
restores the default functionality (useful for use on child elements of an element withpointer-events: none;
specifiedinherit
will use thepointer-events
value of the element's parent
pointer-events
is to allow click or tap behavior to “pass through” an element to another element below it on the Z axis. For example, this would be useful for graphic overlays, or hiding elements with opacity
(eg. tool tips) and still allowing text-selection on the content below it.Syntax
/* Keyword values */
pointer-events: auto;
pointer-events: none;
pointer-events: visiblePainted;
pointer-events: visibleFill;
pointer-events: visibleStroke;
pointer-events: visible;
pointer-events: painted;
pointer-events: fill;
pointer-events: stroke;
pointer-events: all;
/* Global values */
pointer-events: inherit;
pointer-events: initial;
pointer-events: unset;
Values
auto
- The element behaves as it would if the
pointer-events
property were not specified. In SVG content, this value and the valuevisiblePainted
have the same effect. none
- The element is never the target of mouse events; however, mouse events may target its descendant elements if those descendants have
pointer-events
set to some other value. In these circumstances, mouse events will trigger event listeners on this parent element as appropriate on their way to/from the descendant during the event capture/bubble phases. visiblePainted
- SVG only. The element can only be the target of a mouse event when the
visibility
property is set tovisible
and when the mouse cursor is over the interior (i.e., 'fill') of the element and thefill
property is set to a value other thannone
, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and thestroke
property is set to a value other thannone
. visibleFill
- SVG only. The element can only be the target of a mouse event when the
visibility
property is set tovisible
and when the mouse cursor is over the interior (i.e., fill) of the element. The value of thefill
property does not affect event processing. visibleStroke
- SVG only. The element can only be the target of a mouse event when the
visibility
property is set tovisible
and when the mouse cursor is over the perimeter (i.e., stroke) of the element. The value of thestroke
property does not affect event processing. visible
- SVG only. The element can be the target of a mouse event when the
visibility
property is set tovisible
and the mouse cursor is over either the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of thefill
andstroke
do not affect event processing. painted
- SVG only. The element can only be the target of a mouse event when the mouse cursor is over the interior (i.e., 'fill') of the element and the
fill
property is set to a value other thannone
, or when the mouse cursor is over the perimeter (i.e., 'stroke') of the element and thestroke
property is set to a value other thannone
. The value of thevisibility
property does not affect event processing. fill
- SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) of the element. The values of the
fill
andvisibility
properties do not affect event processing. stroke
- SVG only. The element can only be the target of a mouse event when the pointer is over the perimeter (i.e., stroke) of the element. The values of the
stroke
andvisibility
properties do not affect event processing. all
- SVG only. The element can only be the target of a mouse event when the pointer is over the interior (i.e., fill) or the perimeter (i.e., stroke) of the element. The values of the
fill
,stroke
andvisibility
properties do not affect event processing.
Comments
Post a Comment