Two columns flex-box layout

Viewed 61200

I need create layout which will contain list of items in two columns. Like i showed below:

.container {
  border: 1px solid red;
  height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.item {
  border: 1px dashed blue;
  height: 50px;
}
<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>
But there is a problem with such layout. If there will be only 1 item - it will take full width. And i need to keep columns even if there are a few items.

1 Answers
Related