1

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>&lt;</option>
            <option>&lt;=</option>
            <option>=</option>
    </select>
    <span class="no-wrap">Plan Duration [d]</span>
    <select>
            <option>&lt;</option>
            <option>&lt;=</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?

kukkuz
  • 41,512
  • 6
  • 59
  • 95
Tom
  • 195
  • 9

0 Answers0