Set minimum items per row with Flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Row

Description

Set minimum items per row with Flexbox

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

.container {<!--  ww w.  j av  a 2  s . co  m-->
   display: flex;
   flex-flow: row nowrap;
}
.container > div {
   padding: 49px 0;
   text-align: center;
   flex: 1;
   box-sizing: border-box;
}
input[type=button] {
   background: red;
}
@media ( max-width: 700px) {
   .container { flex-wrap: wrap; }
   .container > div { flex-basis: 33.33%; }
}
@media ( max-width: 400px) {
   .container > div { flex-basis: 50%; }
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div> 
    <input type="button" value="Button 1"> 
   </div> 
   <div> 
    <input type="button" value="Button 2"> 
   </div> 
   <div> 
    <input type="button" value="Button 3"> 
   </div> 
   <div> 
    <input type="button" value="Button 4"> 
   </div> 
   <div> 
    <input type="button" value="Button 5"> 
   </div> 
   <div> 
    <input type="button" value="Button 6"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials