4

Example code: https://jsfiddle.net/z7ybks9u/2/

Motivation: I would like to force a 3 column layout, WITH support for fixed width but variable height DIVS, wit layout efficiency that will not expose large "whitespace holes" between items. Since the number of elements is unknown, I cannot limit the height of the flex container.

Problem: without forcing the height of the flex container, I cannot see more than one column, as it just utilizes the vertical space it needs to fit all items in one column.

What I am forced to do:

gallery-height {

      display: flex;
      flex-direction: column;
      flex-wrap: wrap;
      align-content: center;
      max-height: 700px;   <-----  NEED TO DO THAT TO SEE COLUMNS BUT I HAVE TO SUPPORT UNKNOWN NBR OF ELEMENTS
    }
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
JasonGenX
  • 4,952
  • 27
  • 106
  • 198

1 Answers1

6

Dropping the Flex container in favor of column-count might help: https://jsfiddle.net/69nmwqag/

.gallery-height {
  column-count: 3;
}

Then I dropped width: 30%; on .img.

Mike
  • 251
  • 1
  • 6