What I have now, when the size of the window changes, the boxes correspond accordingly to the width. However, I want at least two boxes to move to the next line instead of 3 on top and 1.
Is this possible with flexbox, and if not, how would this be done?
script: 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>
Run codeHide result
source
share