Reputation: 1199
I am trying to achieve a grid with three columns:
If column three ends up taking x% of width than column two should be 50-x% in width.
Upvotes: 0
Views: 356
Reputation: 87191
Give the first item flex-basis: 50%
and the middle flex-grow: 1
.
This will make the first 50% wide, the last as wide as its content and the middle fill the remaining space left
.wrapper {
display: flex;
}
.wrapper .item {
border: 1px dotted gray;
}
.wrapper .item:first-child {
flex-basis: 50%;
}
.wrapper .item:nth-child(2) {
flex-grow: 1;
}
<div class="wrapper">
<div class="item">50%
</div>
<div class="item">Fill remaining
</div>
<div class="item">Button
</div>
</div>
Upvotes: 1