Add a scrollbar to a DIV that contains a table - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div Table

Description

Add a scrollbar to a DIV that contains a table

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">
div {<!--  w  w  w.  jav a  2 s  .co  m-->
   overflow-y:auto;
   height:100px;
}
</style> 
 </head> 
 <body> 
  <div class="box"> 
   <table> 
    <tbody> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
     <tr> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
      <td>Lorem i</td> 
     </tr> 
    </tbody> 
   </table> 
  </div>  
 </body>
</html>

Related Tutorials