Align scrollable table columns with header - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

Align scrollable table columns with header

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">
* {<!--  w  w w .j a va 2  s.c om-->
   box-sizing:border-box;
}

th {
   width:100px;
   padding:0;
   display:inline-block;
}

td {
   width:100px;
   padding:0;
   display:inline-block;
}
</style> 
 </head> 
 <body> 
  <table cellspacing="0" cellpadding="0" border="0" width="325"> 
   <tbody> 
    <tr> 
     <td> 
      <table cellspacing="0" cellpadding="1" border="1" width="300"> 
       <tbody> 
        <tr> 
         <th>Full Name</th> 
         <th>Status</th> 
         <th>Last reported</th> 
        </tr> 
       </tbody> 
      </table> </td> 
    </tr> 
    <tr> 
     <td> 
      <div class="cont" style="width:325px; height:48px; overflow:auto;"> 
       <table class="data" cellspacing="0" cellpadding="1" border="1" width="300"> 
        <tbody> 
         <tr> 
          <td>col 1 data 1</td> 
          <td>col 2 data 1</td> 
          <td>col 3 data 1</td> 
         </tr> 
         <tr> 
          <td>col 1 data 2</td> 
          <td>col 2 data 2</td> 
          <td>col 3 data 2</td> 
         </tr> 
         <tr> 
          <td>col 1 data 3</td> 
          <td>col 2 data 3</td> 
          <td>col 3 data 3</td> 
         </tr> 
        </tbody> 
       </table> 
      </div> </td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials