Masonry layout with css3 flex - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Container

Description

Masonry layout with css3 flex

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">

.flex-c {<!--from   ww  w . ja  v a  2  s  . com-->
   transform: rotate(90deg) scaleY(-1);
   transform-origin: left top;
   overflow: hidden;
}
.flex-c:after {
   content: '';
   display: table;
   clear: both;
}
.flex-i.red { background-color: red; }
.flex-i.blue {background-color: blue; }
.flex-i.green {background-color: green;}
.flex-i {
   transform: rotate(90deg) scaleY(-1);
   height: 100px;
   width: 100px;
   background-color: gray;
   margin: 0 10px 10px 0;
   float: left;
}
.flex-i:after,
.flex-i.big:before {
   content: '';
   height: 100px;
   width: 100px;
   left: 110px;
   top: 0;
   position: absolute;
   background-color: pink;
}
.flex-i.big:after {
   left: 220px;
}
.flex-i.big:before {
   left: 220px;
   bottom: 0;
   top: auto;
}
.big {
   width: 210px;
   height: 210px;
}


      </style> 
 </head> 
 <body> 
  <div class="wrap"> 
   <div class="flex-c"> 
    <div class="flex-i big"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i big green"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
    <div class="flex-i green"></div> 
    <div class="flex-i red"></div> 
    <div class="flex-i blue"></div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials