z-index and hover interactions
I have started to build an hexagonal map using the
oi.hexmap.js
library as shown in this CodePen.
I have an issue with conflicting z-index that I'm not sure can even be solved. I have a base div with id="hexmap1"
which host the map. Inside that div, I have another one with id="compass"
which has a background picture.
The library creates an hex grid inside hexmap1
which goes over compass because it's executed (The javascript) after everything in the DOM has been loaded. So I bump the z-index of compass to have it above the hex grid (Because this is what I want).
When you hover over an hex, it gets a new class hover
which I use to make it bigger and more visible. However, if an hex is close enough to compass
, when hovered it will appear behind compass which is logical.
So I tried to bump the z-index of the hex using different ways:
- By selecting #hexmap1 .hover path
- By selecting .hex:hover
None of that worked and I'm wondering if that's even possible to get the behavior I'm looking as the hexes are children of the hex grid.
Is there a solution to this problem or it's simply impossible the way the things are built? What I want is that normal hexes stay under the compass <div> but that they move above that same div if hovered over.1 Reply
It's important to note that the final HMTL layout produced by the Javascript looks like that:
The
#compass
div is sharing a common parent (#hexmap1
) with the hexes but the hexes are nested inside more divs. That might explain why I can't use z-index
like I want because they are not part of the same "stack".
But maybe there are some magic tricks I'm not aware of that could solve this issue. 🙂