Use Flexbox: space-between to leave space between items - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex

Description

Use Flexbox: space-between to leave space between items

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
 </head> <!-- w w  w.  j av a2  s  .c o m-->
 <body> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
  <meta http-equiv="X-UA-Compatible" content="ie=edge"> 
  <title>Document</title> 
  <style>
* {
   box-sizing:border-box;
}

.grid {
   border:2px dashed Chartreuse;
   display:flex;
   flex-flow:column nowrap;
   justify-content:space-between;
   align-items:center;
   height:100vh;
}

.grid * {
}
.box {
   height:100px;
   width:100px;
   background-color:yellow;
}
</style> 
  <div class="grid"> 
   <div class="box">
     1 
   </div> 
   <div class="box">
     2 
   </div> 
   <div class="box">
     3 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials