show divs in one column on web and two columns on mobile - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:2 Column

Description

show divs in one column on web and two columns on mobile

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

.wrapper > div {
   border:1px solid; 
   height:100px; 
}
@media screen and (max-width: 300px) {  
    .wrapper {<!-- ww  w .j a v  a2 s  .co m-->
       -webkit-column-count:2; 
       -moz-column-count:2;
       column-count:2; 
    }
}


      </style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div id="1">
     1 
   </div> 
   <div id="2">
     2 
   </div> 
   <div id="3">
     3 
   </div> 
   <div id="4">
     4 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials