I have a flexbox
inside of an absolutely positioned parent div
. I expect the flexbox
to have a computed width
, causing the parent div to expand, but this doesn't happen. The parent div has some width, but it is not wide enough to accommodate the flexbox.
Given that the flexbox has four children, each with flex-basis: 100px
, and flex-shrink: 0
, I'd expect the flexbox to have a width of 400px
, causing the parent div to expand to 400px
of content width. It is instead expanding to a seemingly arbitrary 255px
.
.parent {
position: absolute;
padding: 10px;
background: red;
}
.flex {
display: flex;
}
.flex-child {
flex: 1 0 100px;
background: #EEE;
border: 1px solid black;
white-space: nowrap;
overflow: hidden;
}
<div class="parent">
<div class="flex">
<div class="flex-child">One</div>
<div class="flex-child">Two</div>
<div class="flex-child">Three (really really long)</div>
<div class="flex-child">Four</div>
</div>
</div>
min-width: max-content;
on the.flex
container works. – Delrosario