Create a responsive two-column layout using flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Column

Description

Create a responsive two-column layout using 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">
* {<!--   ww  w  .  j a v a2  s .  co  m-->
   margin:0;
   box-sizing:border-box;
}

html, body {
   height:100%;
}

.collection {
   display:flex;
   flex-direction:column;
   flex-wrap:wrap;
   height:100%;
}

.collection section {
   width:51%;
   flex:2;
   border:2px dashed Chartreuse;
}

.collection section:last-child {
   flex-basis:100%;
}

@media ( max-width: 700px )  {
   .collection section {
      width:100%;
   }
   
   .collection section:last-child {
      flex-basis:auto;
   }

}
</style> 
 </head> 
 <body> 
  <div class="collection"> 
   <section> 
    <h2>bar</h2> 
   </section> 
   <section> 
    <h3>baz</h3> 
   </section> 
   <section> 
    <h1>FOO</h1> 
   </section> 
  </div>  
 </body>
</html>

Related Tutorials