I have a webpage where two divs are on top of each other, and both are the same width, so the top div completely covers the bottom div. The challenge: I need users to be able to interact with the lower div. By interact, I mean click, hover (as determined using mouseenter
and mouseleave
in JS), highlight text, etc.
I'm already familiar with pointer-events
(as discussed here), but setting it to none
on the top div hasn't resolved the issue. Is there anything I can do to make the lower div interactive without placing it above the upper div (i.e. without changing its z-index)? Note that I haven't explicitly set the z-index on either div; it's set by their order in the document.
Update: Here's a CodePen demonstrating an example of this behavior. In the actual code I'm working with, .upper
contains nested elements, and the button animation is run in JS (using GSAP) rather than as a CSS animation.