Squares in squares with flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Container

Description

Squares in squares 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">

.parent {<!--from w  w  w  .  jav  a2s. c om-->
   display: flex;
}
.square-container {
   flex: 1;
   display: flex;
   justify-content: space-around;
   align-content: space-between;
   flex-wrap: wrap;
}
.small-square {
   flex: 0 0 45%;
   height: 100px;
   background-color: red;
}
.large-square {
   flex: 1;
   height: 210px;
   margin: 0 5px;
   background-color: red;
}
.square-container:nth-child(2) { order: 1;}


      </style> 
 </head> 
 <body> 
  <div class="parent"> 
   <div class="square-container"> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
   </div> 
   <div class="square-container"> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
    <div class="small-square"></div> 
   </div> 
   <div class="large-square"></div> 
  </div>  
 </body>
</html>

Related Tutorials