Html Table - fixed column width with horizontal scrolling - column widths larger than container - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

Html Table - fixed column width with horizontal scrolling - column widths larger than container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <style>
div.outer<!--from w  w  w. jav a 2s .c o m-->
 {
   width:501px;
   overflow:auto;
}

table
 {
   table-layout:fixed;
   width:100%;
}

th, td
 {
   border:2px solid Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div class="outer"> 
   <div class="scrollable"> 
    <table> 
     <thead> 
      <tr> 
       <th style="width:50px">Lor</th> 
       <th style="width:300px">Lor</th> 
       <th style="width:200px">Lorem</th> 
       <th style="width:200px">Lore</th> 
       <th style="width:200px">Lore</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td>Lor</td> 
       <td>Lorem ipsum dolor sit amet, con</td> 
       <td>Lorem ipsu</td> 
       <td>Lorem ipsum dol</td> 
       <td>Lorem ipsum do</td> 
      </tr> 
      <tr> 
       <td>Lor</td> 
       <td>Lorem ipsum dolo</td> 
       <td>Lorem i</td> 
       <td>Lorem ipsum d</td> 
       <td>Lorem ipsum </td> 
      </tr> 
     </tbody> 
    </table> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials