Table recover when resizing the screen size - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Size

Description

Table recover when resizing the screen size

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">
@media screen and (max-width: 600px)  {
   table, thead, tbody, th, td, tr {
      display:block;
   }<!--from  w w w  .  ja  v a  2s.c o  m-->
   
   thead tr {
      position:absolute;
      top:-10000px;
      left:-10000px;
   }
   
   td {
      border:none;
      position:relative;
      padding-left:51%;
   }
   
   td:before {
      position:absolute;
      top:7px;
      left:7px;
      width:46%;
      padding-right:11px;
      white-space:nowrap;
   }
   
   td:nth-of-type(1):before {
      content:"Test 2";
   }
   
   td:nth-of-type(2):before {
      content:"Test 3";
   }
   
   td:nth-of-type(3):before {
      content:"Test 4";
   }
   
   td:nth-of-type(4):before {
      content:"Test 5";
   }
   
   td:nth-of-type(5):before {
      content:"Test 6";
   }

}
</style> 
 </head> 
 <body> 
  <table class="responsive-table-md"> 
   <thead> 
    <tr> 
     <th>Lorem </th> 
     <th>Lorem </th> 
     <th>Lorem </th> 
     <th>Lorem </th> 
     <th>Lorem </th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
     <td>L</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials