CSS-only photo grid with horizontal fill

726 views Asked by At

I've found a workable CSS-only photo-grid:

https://css-tricks.com/seamless-responsive-photo-grid/

But the fill is vertical; that is, photo #2 is underneath photo #1 in the same column, rather than to the right of it. What I want is horizontal flow.

I can do this easily with JavaScript, but is there a way to do it with pure CSS?

Requirements:

  1. Wrapping must be automatic; I don't want to assign photos to rows.
  2. Left and right justification. The height of a row varies so that the photos in that row are flush to the left and right margins of the container.
  3. The HTML should be extremely simple, something like this:

    <div class='photo-container'>
    <img src='...'>
    <img src='...'>
    <img src='...'>
    ...
    </div>

  4. Aspect ratio of photos must be maintained. [UPDATE]

Any ideas?

0

There are 0 answers