Fix a CSS 3D tilt effect that breaks on hover areas
The tilt handler was never the problem. A 3D parent plane hides half of the rotated card from the pointer, and four small CSS changes fix it.

A card with a mousemove tilt handler works across most of its surface, but in patches the cursor falls back to an arrow and the tilt stops. The patches are not confined to the edges, where the card swings away from the pointer. They show up in the interior too. Deleting the <script> block makes the cursor: pointer work over the whole card again, so the markup and the basic CSS are fine.
This is the situation in a Stack Overflow question about a video-card grid built with plain HTML, CSS and JavaScript. The JavaScript is not at fault. The cause is a hit-testing interaction between the tilted card and its 3D parent, and it affects any tilt effect built the same way. There are four ways to fix it, and they differ in what they cost you.
Everything below refers to the posted CSS: a .videoboxContainer with transform-style: preserve-3d; perspective: 800px, and a .videobox card of 175 by 125 px with transition: transform 0.1s ease-out.
What the symptom tells you
Two observations from the report narrow the search. First, the arrow cursor means the browser decided the pointer is not over .videobox. That is a hit-testing result, not a JavaScript error. Second, the bug disappears without the script, so the only thing that changes between working and broken is the card's transform.
That points away from event listeners and toward geometry. The handler does read the card's bounding rect and compute the pointer position relative to it, and maxRotation is 10, but a bug in that arithmetic would produce a wrong tilt angle, not a cursor that reverts to an arrow. A wrong angle and a failed hit test are different failures. Here only the second is happening.
The CSS that sets the trap
The relevant lines are on the container, not the card:
.videoboxContainer {
transform-style: preserve-3d;
perspective: 800px;
/* flex layout, padding, gap omitted */
}
.videobox {
cursor: pointer;
transition: transform 0.1s ease-out;
}perspective on the container gives its children a vanishing point, so a rotated card has one edge closer to the viewer and one farther away. transform-style: preserve-3d tells the browser to keep children in a shared 3D space instead of flattening them into the container's plane. That is exactly the combination that lets a rotated child pass through its parent's plane.
The container has no background of its own, so nothing on screen shows that it is there. It is still a box, and it still takes part in hit testing.
What happens when the card tilts
The accepted answer gives the mechanism in one sentence: the transformed element tilts and intersects with its parent, so the sunken half gets beneath it and stops receiving pointer events. The card is rotated around its center, so half of it moves toward the viewer and half moves away. The half that moves away sinks behind the container's plane. Where the container is in front of the card, the pointer hits the container.
That explains why the dead zones sit in the interior as well as at the edges. The boundary between the live and dead areas is where the card crosses the container's plane, and it runs through the middle of the card. It also explains why the effect feels random: the dead area moves with every mouse position, because the tilt angle follows the pointer.
See it before you fix it
The answer's debugging trick is to colour the boxes. Give the container a blue background and the card a red one, and the intersection becomes visible: part of the red card disappears behind the blue. It takes a few seconds and confirms the diagnosis before you change anything.
A second check that needs no style changes is to run document.elementFromPoint(x, y) in the console with coordinates inside a dead zone. If it returns the container instead of the card, you have confirmed the hit-test theory. If it returns something unexpected, such as an overlay with pointer-events set, you have a different bug that happens to look similar.
Remember to remove the debug colours afterwards. The second answer left background-color: green on the container in its demo for exactly this purpose, so copying its CSS verbatim ships a green container.
Fix one: lift the card above the container
The first answer suggests pulling the card forward, for example with translateZ(50px). If the card sits in front of the container's plane, tilting it by a few degrees can no longer sink one half behind that plane, because the card's far edge stays on the viewer's side. The answer also notes this reduces the perspective 'zoom', the apparent growth of the edge that swings toward the viewer.
The catch is that translateZ also changes apparent size. Under the perspective formula, an element moved toward the viewer by 50px with perspective: 800px renders at 800 / (800 − 50), about 6.7 percent larger, before any tilt. You will likely need to compensate in the card's dimensions. The margin also depends on your tilt range: a larger maxRotation needs more lift, and you have to keep the two numbers consistent by hand.
Fix two: switch pointer events off on the container
Both answers offer this one. If the container never takes pointer events, it cannot win a hit test against the card. The second answer shows the pattern:
.videoboxContainer {
transform-style: preserve-3d;
perspective: 800px;
pointer-events: none;
}
.videobox {
pointer-events: all;
cursor: pointer;
}pointer-events is an inherited property, so the card would otherwise inherit none from its parent. That is why the override on .videobox is required, not optional. The answer's text writes it as all, while the first answer's text spells it pointer-event, singular. The singular form is not a CSS property and would be silently ignored, so check the spelling when you copy it.
Fix three: isolate the card or flatten the container
The first answer lists two structural fixes. One, raised in a comment, is to give the card its own stacking context with isolation: isolate, or any other property that creates one. The other is to remove transform-style: preserve-3d from the container, or make it flat, so the browser stops computing intersections between the card and its parent entirely.
Flattening is the simplest change when the container exists only for layout. A flex wrapper that arranges cards in a row does not need a 3D context of its own, and perspective can stay on it, since that property is what gives the children their vanishing point. If something else in the page relies on the shared 3D space, such as nested layers moving at different depths, flattening will break that, and one of the other fixes is a better fit.
Why the thumbnail and text already have pointer-events: none
The original CSS sets pointer-events: none on .videoThumbnail and .videoInfo. That is a deliberate choice, and a good one for tilt effects. It means the event target is always the card, never a child image or text span, so the handler's pointer maths and the hover state refer to a single element.
It is also why those declarations are not the bug. They remove children from hit testing, but they do nothing about the parent winning hit tests against the card. It is easy to look at the existing pointer-events rules, assume they have been dealt with, and miss the one place that needs one.
Where this does not fit, and what to watch for
The container-level pointer-events: none fix has side effects. Clicks on the container's padding or gaps go straight through it, so any behaviour attached to the container itself, such as a click-away handler, stops working. Any other child that needs interaction, like a button in the same wrapper, must have the property restored on it individually.
The translateZ fix is fragile if the tilt range grows or the layout changes depth, because the safe lift depends on the card's size and rotation. The flattening fix gives up the shared 3D space. Choose by what the container is for: layout only, flatten it; mixed content, restore pointer events on the card; a deliberate 3D scene, lift the cards.
One more issue sits near this bug and is easy to confuse with it. getBoundingClientRect() on a rotated element returns the box that encloses the transformed shape, not the original rectangle. A handler that recomputes its pointer position from that rect on every mousemove is working against a rectangle that moves as the card tilts. Whether that matters depends on the part of the handler that was cut off from the posted code, so it is worth testing at the card's edges after you fix hit testing.
This article draws on 3D tilt effect with JS working only in highly specific areas of the element and answers to it (1, 2), on the Stack Exchange network, licensed under CC BY-SA 4.0.
- #3D tilt effect
- #css
- #html
- #javascript
- #pointer-events
- #transform-style preserve-3d



Comments