1

This CSS almost does what is needed:

  • always fill the container 100% so no margin is seen.
  • resize images to fill the container without media queries or calculations.

but certain screen sizes create a larger image than is wanted

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-gap: 6px;
}

the 1fr does great EXCEPT for when the images get too big. If I use minmax(200px, 300px), then most of the time, the margins get too big.

Is there a way to get the benefits of 1fr, but also have a max-width as well? so resizing the images SMALLER is okay, but increasing the image size is not okay.

itsMasoud
  • 1,335
  • 2
  • 9
  • 25
user1864734
  • 135
  • 3
  • 13

0 Answers0