I want to create an inline form which uses 100% width of its parent container and expands the input to fill any unused space.
The code I came up with: https://jsfiddle.net/k8Lbm1we/
.container {
width: 500px;
background-color: #CDCDCD;
padding: 15px;
}
.form-inline-expanded {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
.form-inline-expanded input {
flex-grow: 1;
//width: 100%;
}
.form-inline-expanded .no-wrap {
flex-shrink: 0;
}
.form-inline-expanded *:not(:first-child) {
margin-left: 3px;
}
}
<div class="container">
<div class="form-inline-expanded">
<input />
<select>
<option><</option>
<option><=</option>
<option>=</option>
</select>
<span class="no-wrap">Plan Duration [d]</span>
<select>
<option><</option>
<option><=</option>
<option>=</option>
</select>
<input />
</div>
</div>
Firefox works as expected. Chrome and Edge expands beyond the parent container.
If I replace the flex-grow: 1
with width: 100%
it works in Chrome but Firefox displays the dropdowns to small and Edge does not take the margin into account.
What is the issue here?