* {
  box-sizing: border-box;
}

div.gallery {
  border: 1px solid #ccc;
}

div.gallery:hover {
  border: 1px solid #777;
}

/* Force all images to uniform dimensions */
div.gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

div.desc {
  padding: 15px;
  text-align: center;
}

.responsive-gallery {
  padding: 0 6px;
  float: left;
  width: 25%;
  margin-bottom: 12px;
}

/* Clear float on every 4th element automatically in CSS */
.responsive-gallery:nth-child(4n+1) {
  clear: left;
}

@media only screen and (max-width: 700px) {
  .responsive-gallery {
    width: 50%;
  }
  .responsive-gallery:nth-child(4n+1) {
    clear: none;
  }
  .responsive-gallery:nth-child(2n+1) {
    clear: left;
  }
}

@media only screen and (max-width: 500px) {
  .responsive-gallery {
    width: 100%;
  }
  .responsive-gallery:nth-child(2n+1) {
    clear: none;
  }
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}