Responsive 4 column grid turns to 3 column grid on resize - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive 4 column grid turns to 3 column grid on resize

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">
.box<!-- w  ww .jav a2 s  .c  o  m-->
 {
   width:23%;
   margin:0px 2.6%;
   background-color:Chartreuse;
   color:yellow;
   float:left;
}

@media screen and (max-width:500px)
 {
   .box
    {
      width:31%;
   }
   
   .box:last-child
    {
      display:none;
   }

}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="box">
     Lorem i 
   </div> 
   <div class="box">
     Lorem ip 
   </div> 
   <div class="box">
     Lorem i 
   </div> 
   <div class="box">
     Lorem ip 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials