HTML CSS examples for CSS Layout:Flex Wrap
Make flex items wrap two at a time
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .line{<!--from ww w . j a v a2s .c o m--> 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; } @media ( max-width: 800px ) { .box { flex-basis: calc(50% - 20px); margin: 10px; } } </style> </head> <body> <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> </body> </html>