Making flexbox wrapped items consume vertical space

I'm trying to implement a "collage" layout with flexbox where the items are of undefined heights, but the fixed width can be "left" in a collage style (sort of like pintrest), but I'm having trouble getting the flex items to absorb the extra VERTICAL space.

HMTL

<div class="widget-wrap">
    <div class="widget"> <!-- these elements are generated dynamically -->
        <!-- ~ indeterminate amount of content resulting of varying height ~ -->
    </div>
</div>

      

CSS

.widget-wrap { 
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}

.widget {
    width: 33.33333%;
    margin-bottom: 0; /* my best guess */
}

      

RESULT

enter image description here

As you can see, there are vertical spacing when one widget is larger than the others on the same line (I assume this was expected with align-items: flex-start

), but I would like all elements in subsequent lines to be meaningfully aligned to the element above them in my column, for example on pintrest .

+3
html css flexbox gridview


source to share


No one has answered this question yet

See similar questions:

nineteen
Is it possible for the flex elements to fit snugly against the elements above them?

or similar:

1839
Make the cursor a hand when the user hovers over a list item
1630
Make a div to fill the height of the remaining screen.
565
Flexbox: center horizontally and vertically
553
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
336
How do I vertically align text inside flexbox?
299
Flex-box: align the last line with the grid
154
Fill the remaining vertical space with CSS using display: flex
128
When flexbox items are wrapped in column mode, the container does not expand its width
72
How can I make my flexbox layout take up 100% vertical space?
7
Providing wrapped flexbox items with vertical spacing



All Articles
Loading...
X
Show
Funny
Dev
Pics