Make flex items wrap two at a time

Viewed 2880

What I have now is when the window re-sizes, the boxes adjust accordingly to fit the width. However, what I want is to have a minimum of two boxes move to the next line instead of 3 on top and 1.

Is this achievable with flexbox and if not, how would I accomplish this?

fiddle: https://jsfiddle.net/jzhang172/cqdwLyxu/

.line{
  display:flex;
  width:100%;
  margin-bottom:30px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  
}
body,html{
  margin:0;
  padding:0;
  position:relative;
}
*{
  box-sizing:border-box;
}
.box{
  width:200px;
  min-width:200px;
  background:blue;
  margin:0 10px 0 10px;
  height:200px;
}
<div class="line">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div>
<div class="line">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div>

1 Answers
Related