Display Different table/grid layout for different device sizes - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Grid

Description

Display Different table/grid layout for different device sizes

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">
* {<!--from w w w.  j  a v a  2s. c o  m-->
   box-sizing:border-box
}

.cf:before,
.cf:after {
   content:" ";
   display:table;
}

.cf:after {
   clear:both;
}

.row {
   margin-left:-11px;
   margin-right:-11px;
}

.content-block {
   float:left;
   width:51%;
   padding-left:11px;
   padding-right:11px;
   padding-bottom:21px;
   text-align:center;
}

.content-block .inner-content {
   background-color:Chartreuse;
   padding:21px
}

@media only screen and (max-width: 767px)  {
   .content-block {
      width:100%;
      float:none;
      padding-left:0;
      padding-right:0
   }
   
   .row {
      margin-left:0;
      margin-right:0;
   }

}
</style> 
 </head> 
 <body> 
  <div class="row cf"> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
  </div> 
  <div class="row cf"> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
  </div> 
  <div class="row cf"> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
   <div class="content-block"> 
    <div class="inner-content">
      Lor 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials