I'm looking for flexbox in a grid cell which:
- flows in the column direction
- uses a minimum height before wrapping
- grows in height if all width is filled while wrapping
It's a bit hard to explain in words, hopefully an example should make things clearer. In the example below, I'd like content
, to always be a minimum of 100px tall. However, content
should not be taller than this unless it has first filled all of the horizontal space in the grid cell.
Is this possible to do somehow?
.grid {
display: grid;
grid-template-columns: auto 200px;
grid-template-rows: auto min-content;
grid-template-areas: "header header" "content sidebar";
}
header {
grid-area: header;
background: red;
}
.content {
grid-area: content;
min-height: 100px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-start;
}
.content-block {
border: 2px solid green;
height: 100px;
width: 50px;
}
.sidebar {
grid-area: sidebar;
background: blue;
}
<div class="grid">
<header>title</header>
<div class="content">
<div style="height: 50px" class="content-block"></div>
<div style="height: 75px" class="content-block"></div>
<div style="height: 110px" class="content-block"></div>
<div style="height: 80px" class="content-block"></div>
<div style="height: 40px" class="content-block"></div>
<div style="height: 40px" class="content-block"></div>
</div>
<div class="sidebar">
sidebar
</div>
</div>