Create 3 Column Responsive layout using CSS via changing width of div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:3 Column

Description

Create 3 Column Responsive layout using CSS via changing width of div

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">
.section {<!--  w ww.  j  av  a 2 s  .c om-->
   clear:both;
   padding:0px;
   margin:0px;
}

.a {
   background-color:Chartreuse;
}

.b {
   background-color:yellow;
}

.c {
   background-color:blue;
}

@media only screen and (min-width: 480px)  {
   .span_3_of_3 {
      width:100%;
   }
   
   .span_2_of_3 {
      width:67.2%;
   }
   
   .span_1_of_3 {
      width:33.3%;
   }
   
   .col {
      display:block;
      float:left;
      margin:2% 0 2% 2.7%;
   }
   
   .col:first-child {
      margin-left:0;
   }

}

@media only screen and (max-width: 480px)  {
   .section {
      width:100%;
      display:-webkit-box;
      display:-moz-box;
      display:-webkit-flexbox;
      display:-ms-flexbox;
      display:-webkit-flex;
      display:flex;
      -webkit-box-orient:vertical;
      -moz-box-orient:vertical;
      -webkit-box-direction:normal;
      -moz-box-direction:normal;
      -webkit-flex-direction:column;
      -ms-flex-direction:column;
      flex-direction:column;
   }
   
   .a {
      -webkit-box-ordinal-group:3;
      -moz-box-ordinal-group:3;
      -webkit-flex-order:2;
      -ms-flex-order:2;
      -webkit-order:2;
      order:2;
   }
   
   .b {
      -webkit-box-ordinal-group:4;
      -moz-box-ordinal-group:4;
      -webkit-flex-order:3;
      -ms-flex-order:3;
      -webkit-order:3;
      order:3;
   }

}
</style> 
 </head> 
 <body> 
  <div class="section group"> 
   <div class="col span_1_of_3 a">
     This is column 1 
   </div> 
   <div class="col span_1_of_3 b">
     This is column 2 
   </div> 
   <div class="col span_1_of_3 c">
     This is column 3 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials