Convert a two column stack into a single with @media queries - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:2 Column

Description

Convert a two column stack into a single with @media queries

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

.posts > div {
   width: 100%;
}
@media all and (min-width: 600px) {
   .posts > div {
      width: 50%;
   }<!--from  w w w.  ja  v a2  s  .  c  o  m-->
   .posts > div:nth-child(2n) {
      float: left;
   }
   .posts > div:nth-child(2n+1) {
      float: right;
   }
}


      </style> 
 </head> 
 <body> 
  <div class="posts"> 
   <div>
     Post Content1 
   </div> 
   <div>
     Post Content2 
   </div> 
   <div>
     Post Content3 
   </div> 
   <div>
     Post Content4 
   </div> 
   <div>
     Post Content5 
   </div> 
   <div>
     Post Content6 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials