Example:
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}div.gallery {
border: 1px solid gray;
}div.gallery:hover {
border: 1px solid #000;
}div.gallery img {
width: 100%;
height: auto;
}div.desc {
padding: 10px;
text-align: center;
}.responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
}@media only screen and (max-width: 768px) {
.responsive {
width: 50%;
margin: 6px 0;
} }@media only screen and (max-width: 576px) {
.responsive {
width: 100%;
} }</style>
</head>
<body>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="sample.jpg">
<img src="sample.jpg" alt="css image gallery-sample image" width="700" height="400">
</a>
<div class="desc">Description of Image</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="sample.jpg">
<img src="sample.jpg" alt="css image gallery-sample image" width="700" height="400">
</a>
<div class="desc">Description of Image</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="sample.jpg">
<img src="sample.jpg" alt="css image gallery-sample image" width="700" height="400">
</a>
<div class="desc">Description of Image</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="sample.jpg">
<img src="sample.jpg" alt="css image gallery-sample image" width="700" height="400">
</a>
<div class="desc">Description of Image</div>
</div>
</div>
</body>
</html>