In my layout, I have three vertically stacked items within a column. What I'm trying to achieve is to center the middle item (green) within the column and have the other items attached to that.
What I have:
.flex-row {
display: flex;
flex-direction: row;
}
.flex-col {
display: flex;
flex-direction: column;
}
.flex-start {
display: flex;
justify-content: flex-start;
}
.flex-center {
display: flex;
justify-content: center;
align-items: center;
}
.flex-end {
display: flex;
justify-content: flex-end;
}
.col {
width: 50px;
min-height: 250px;
margin: 5px;
}
.item {
width: 40px;
height: 40px;
margin: 5px;
}
.long {
height: 60px;
}
.red {
background: red;
}
.blue {
background: blue;
}
.green {
background: green;
}
.yellow {
background: yellow;
}
<div class="flex-row">
<div class="red col flex-center">
<div class="flex-col">
<div class="blue item"></div>
<div class="green item"></div>
<div class="yellow item long"></div>
</div>
</div>
<div class="red col flex-center">
<div class="flex-col">
<div class="blue item long"></div>
<div class="green item"></div>
<div class="yellow item"></div>
</div>
</div>
<div class="red col flex-center">
<div class="flex-col">
<div class="blue item long"></div>
<div class="green item"></div>
<div class="yellow item long"></div>
</div>
</div>
</div>
What I'm aiming at:
It should be noted that the center items (green) have a fixed height, while the other's height (blue and yellow) is determined by the content. I could set a fixed size on the columns as well, but I'd prefer it be flexible and adapt to the height of the contained items.