I am working on a gallery project and I would like each photo to expand to full screen when clicked, similar to this example:
https://i.sstatic.net/nRWsV.jpg
Currently, my code includes a click handler on each image that adds a class zoom
to the clicked image. However, my CSS only enlarges the image without centering it on the entire page as shown in the example. Here is my current code snippet:
.gallery img {
width: 100%;
height: 100%;
object-fit: cover;
align-content: center;
object-position: center;
transition: transform ease-in-out 0.5s;
}
.zoom {
z-index: 1;
transform: scale(1.5);
display: block;
margin-left: auto;
margin-right: auto;
}
<body onload="getPics()">
<div class="container">
<h1>Photo Gallery</h1>
<div class="gallery">
<img
src="https://images.unsplash.com/photo-1543517515-d6ff15a98642?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjQ0NDc3fQ&s=493802e93ec426171750ac2291e2867e"
/><img
src="https://images.unsplash.com/photo-1543517515-d6ff15a98642?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjQ0NDc3fQ&s=493802e93ec426171750ac2291e2867e"
/><img
src="https://images.unsplash.com/photo-1543517515-d6ff15a98642?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjQ0NDc3fQ&s=493802e93ec426171750ac2291e2867e"
/>
</div>
</div>
</body>
How can I modify the zoom
CSS to make the image go into full-screen mode?