Student-friendly HTML, CSS, and JavaScript reference with examples
The pointer-events property controls whether an element can be the target of mouse clicks.
Makes the element “invisible” to clicks — the click passes through to whatever is behind it.
.overlay {
pointer-events: none;
}
This is useful when you stack images on top of each other (like a unit on a hex tile). Without this, clicking the top image won’t trigger the click event on the element behind it.
The element responds to clicks normally.
.overlay {
pointer-events: auto;
}
.hex-container {
position: relative;
}
.hex-background {
position: absolute;
}
.unit-overlay {
position: absolute;
pointer-events: none; /* clicks pass through to hex */
}
Now clicking the unit image actually fires the click event on the hex background behind it.