That's because there is a circular definition:
- The size of the
#inner-wrapper
depends on the size of the input and the button via min-width: auto
.
- The sizes of the input and the button depend on the size of
#inner-wrapper
via flex properties.
Therefore, #inner-wrapper
is sized according to the intrinsic width of the button and the input.
If you don't want that, you can break the circular definition manually:
Make #inner-wrapper
ignore the sizes of its contents
#inner-wrapper {
min-width: 0;
}
#outer-wrapper {
max-width: 105px;
display: flex;
overflow: hidden;
}
#inner-wrapper {
flex: 1;
min-width: 0;
display: flex;
}
input, button {
min-width: 0;
flex: 2;
}
<div id="outer-wrapper">
<div id="inner-wrapper">
<input />
<button></button>
</div>
</div>
Make the input and button ignore their intrinsic width.
input, button {
width: 0;
}
#outer-wrapper {
max-width: 105px;
display: flex;
overflow: hidden;
}
#inner-wrapper {
flex: 1;
display: flex;
}
input, button {
width: 0;
min-width: 0;
flex: 2;
}
<div id="outer-wrapper">
<div id="inner-wrapper">
<input />
<button></button>
</div>
</div>