When you click on a thumbnail image, a full-screen overlay with a larger version of the image will be triggered using JavaScript.
To ensure that the image is centered and resized inside the black overlay when the browser window size changes, I attempted the following:
$(document).ready(function() {
$('.gallery_pics').click(function(e) {
$(this).toggleClass('fullscreen');
});
});
.gallery_pics_holder {
border: px solid green;
width: 100%;
text-align: center;
height: 350px;
display: table;
}
.gallery_pics {
display: inline-block;
width: 150px;
height: 150px;
margin: 10px;
text-align: center;
background-color: #3C0;
}
.gallery_pics img {
width: 100%;
height: 100%;
}
.gallery_pics:hover {
cursor: pointer;
}
.gallery_pics.fullscreen {
z-index: 9999;
position: fixed;
margin: 0 auto;
width: 95%;
height: 95%;
top: 2%;
left: 3%;
background-color: #000;
display: inline-table;
}
.gallery_pics.fullscreen img {
margin: 0 auto;
text-align: center;
max-width: 1099px;
height: auto;
vertical-align: middle;
text-align: center;
display: table-cell;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="gallery_pics_holder">
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/1">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/2">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/3">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/4">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/5">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/6">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/7">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/8">
</div>
<div class="gallery_pics">
<img src="http://lorempixel.com/800/800/sports/9">
</div>
</div>