2

Why is the input overflowing? Allocate space not equally

I want an input width of 300 / 4 px (Ignore the border )

<div style="display: flex; width: 300px; background: red; padding: 5px;">
  <input style="flex: 1;">
  <input style="flex: 1;">
  <input style="flex: 1;">
  <input style="flex: 1;">
</div>
ebyte
  • 1,469
  • 2
  • 17
  • 32

2 Answers2

1

Input has its default min-width which is auto so that reason only flex not able to resize it.

so you have to overwrite it with min-width:0.

input {
  min-width: 0;
}
<div style="display: flex; width: 300px; background: red; padding: 5px;">
  <input style="flex: 1;">
  <input style="flex: 1;">
  <input style="flex: 1;">
  <input style="flex: 1;">
</div>
Sumit Patel
  • 4,530
  • 1
  • 10
  • 28
0

ok, But don't know why

<div style="display: flex; width: 300px; background: red; padding: 5px;">
  <input style="flex: 1; width:0;">
  <input style="flex: 1; width:0;">
  <input style="flex: 1; width:0;">
  <input style="flex: 1; width:0;">
</div>
ebyte
  • 1,469
  • 2
  • 17
  • 32