I have a widget that is composed of three subcomponents:
<div class="container">
<div class="fixed-width"></div>
<div class="flex-width"></div>
<div class="fixed-width"></div>
<div>
And I want the middle component to stretch or shrink based on the width of the container. For this I use flexbox:
.container {
display: flex;
align-items: center;
}
.fixed-width {
flex: 0 0 48px;
}
.flex-width {
flex: 1 1 auto;
}
This works fine when the middle component is a <div>
.
But when I change the middle component to an <input>
element, the <input>
element refuses to shrink to smaller than 173px for some reason.
I can fix it by putting the <input>
in its own container, and give the input width: 100%
, but I don't like creating extra DOM-elements for styling only, and I am curious why the <input>
does not obey my flexbox settings.
What is preventing my <input>
from obeying its css flexbox instructions?
Or is this a known 'bug' in css?
It looks like this:
And here is a codepen that demonstrates the isue: