Currently, I am working on a gallery project where I have successfully implemented functionality to open and close it using separate buttons. However, I am facing an issue where I want the opened gallery to be positioned above all other content on the page, occupying the full width and height without allowing scrolling through the original HTML (similar to how pictures open in Facebook).
Below is the HTML code for the gallery that opens:
<div class="container" id="container-one">
<div class="gallery">
<img src="1.jpg" style="max-width:100%">
</div>
<div class="gallery">
<img src="2.jpeg" style="max-width:100%">
</div>
<a class="close" onclick="Closed()">✖</a>
</div>
Additionally, here is the corresponding CSS:
.container {
display: none;
position: absolute;
}
.gallery {
display: none;
height: fit-content;
width: 99vw;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.6);
background-size: 100%;
z-index: 1300;
text-align: center;
}
I have utilized the style.display property to toggle between displaying and hiding the gallery.
While searching online for solutions, I came across lengthy code snippets for entire galleries which made it difficult for me to isolate the specific part causing this behavior.