I’m working on a page for my website with a gallery of images, the gallery has a fixed height and variable width so that I can continue to add images freely. I have an information menu on the left hand side, full screen height, and I wanted an effect where the gallery would initially be displayed to the right of the menu, and would then go under that element as the user scrolled through.
I have gotten it to display to the right of the menu by having transparent spacer elements, but when I set the gallery z-index to -1 the scroll bar is visible but non functional, it’s trapped under the menu and the gallery can’t be scrolled. Is there a way to fix this?
Here is my current layout for this page of my site. I’ve been setting the crate z-index to 1 for adding images.
2
Answers
Maybe you’re encountering a common issue with z-index and stacking contexts in CSS. Here are a few steps you can try to resolve this:
overflow
Property: If the gallery is not scrolling, you might need to set theoverflow
property on the gallery container:Check for Other Interfering Elements: Ensure no other elements are interfering with the scroll functionality. Sometimes, other elements with higher z-index values can block interactions.
Debugging with Browser Tools: Use browser developer tools to inspect the elements and their computed styles. This can help you see if there are any unexpected styles affecting the layout.
Here’s a more concrete example combining these suggestions:
Try these adjustments and see if they resolve the issue.
Your problem is that the "menubox" occupies the entire view (although it only has content on the right side, the rest is invisible), so when you change the z-index you leave the menubox in front and the scroll is not registering to be related to the gallery.
I think the simplest solution for you would be to add these properties to your menubox in css: