Currently, I'm diving into the world of custom map creation using Leaflet and Mapbox. Everything was going smoothly until I encountered a challenge with the popups.
Here's the issue: I have a unique navigation/control panel that I want to display behind any open popups, but it's not working as intended.
To visualize the problem, I've set up a JSFiddle and included a screenshot:
https://i.sstatic.net/qsxYn.jpg
Here is a snippet of my CSS:
#map-nav {
position: absolute;
left: 10px;
top: 10px;
z-index: 2;
}
.leaflet-popup-pane, .leaflet-popup {
z-index: 1000 !important;
}
While inspecting the code in Firefox/Chrome, I noticed that the z-index is correctly set, and there are no conflicting z-index values in the .leaflet-popup element.
I've heard that using a negative z-index might fix this issue, but I'm looking for a more elegant solution that doesn't feel like a hack. JavaScript solutions are welcome as well.
Upon inspection, Leaflet applies attributes like transform: translate3d(..)
, bottom
, and left
to .leaflet-popup in terms of positioning.
Any assistance on this matter would be greatly appreciated.
Edit:
Even when I nest the #map-nav
inside #map-content
, the issue persists. Here's a fiddle illustrating this. However, when I attempt a similar setup without the map elements, it works.