HTML CSS examples for CSS Layout:Flex Wrap
Make Flexbox wrap items on demand
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .container {<!-- w w w . ja va 2s . c om--> display:flex; } .box { flex:2; height:51px; background-color:Chartreuse; border:2px solid yellow; display:flex; justify-content:center; align-items:center; font-size:2.3em; } @media ( max-width: 800px) { .container { flex-wrap:wrap; } .box { flex:0 0 51%; box-sizing:border-box; } } @media ( max-width: 500px) { .box { flex-basis:100%; } } </style> </head> <body> <div class="container"> <div class="box"> <span>1</span> </div> <div class="box"> <span>2</span> </div> <div class="box"> <span>3</span> </div> <div class="box"> <span>4</span> </div> </div> </body> </html>