Equal width flex items even after they wrap

Viewed 24491

Is it possible to make a pure CSS solution like this:

  1. Items have some min-width.
  2. They should grow dynamically to fill all container width and then wrap to new lines
  3. All items on the list should have equal width.

This is how it looks now:

enter image description here

And this is how I would like it too look like (I've managed those bottom items' width manually just to show the expected result):

enter image description here

.container {
  display: flex;
  flex-wrap: wrap;
}

.item {
  background: yellow;
  min-width: 100px;
  height: 20px;
  text-align: center;
  border: 1px solid red;
  flex-grow: 1;
}
<div class="container">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
  <div class="item">6</div>
  <div class="item">7</div>
  <div class="item">8</div>
  <div class="item">9</div>
  <div class="item">10</div>
</div>

Here is a fiddle demo.

2 Answers
Related