
#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  gap: 1em;
}

#gallery > figcaption {
  grid-column: 1 / -1;
}

#gallery figure {
  position: relative;
}

figure img {
  width: 100%;
  display: block;
} 

#gallery > figure > figcaption {
  position: absolute;
  bottom: 0;
  left: .3em;
  width: 97%;
  line-height: 3em;
  color: white;
  background: rgba(0,0,0,0.3);
}