positioning elements with CSS flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Container

Description

positioning elements with CSS flexbox

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <style>

.top-row, .bottom-row {
   background:red;
   padding:10px;
   display:flex;
}
.box1, .box2, .box3, .box4 {<!-- w  w w .j  av  a  2s.  co m-->
   background:green;
   padding:10px;
   flex: 1;
}
.header {
   background:tan;
   padding:10px;
}
.column1 {
   background:pink;
   padding:10px;
   padding: auto;
   width: 100%;
}
.column2 {
   background:yellow;
   padding:10px;
   padding: auto;
   width: 100%;
}
.col-con {
   display: flex;
}


      </style> 
 </head> 
 <body translate="no"> 
  <div class="top-row"> 
   <div class="box1"> 
    <div class="header"> 
     <form> 
      <input type="text"> 
     </form> 
     <button class="add">+</button> 
     <button class="edit">edit</button> 
    </div> 
    <div class="col-con"> 
     <div class="column1">
       left column 
     </div> 
     <div class="column2">
       right column 
     </div> 
    </div> 
   </div> 
   <div class="box2"> 
    <div class="header"> 
     <button class="add">+</button> 
     <button class="edit">btn1</button> 
     <button class="edit">btn2</button> 
     <button class="edit">btn3</button> 
     <form> 
      <input type="text"> 
     </form> 
    </div> 
    <div class="col-con"> 
     <div class="column1">
       left column 
     </div> 
     <div class="column2">
       right column 
     </div> 
    </div> 
   </div> 
  </div> 
  <div class="bottom-row"> 
   <div class="box3"> 
    <div class="header">
      header 
    </div> 
    <div class="col-con"> 
     <div class="column1">
       left column 
     </div> 
     <div class="column2">
       right column 
     </div> 
    </div> 
   </div> 
   <div class="box4"> 
    <div class="header">
      header 
    </div> 
    <div class="col-con"> 
     <div class="column1">
       left column 
     </div> 
     <div class="column2">
       right column 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials