CSS <td> position fixed with scrollbar - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

CSS <td> position fixed with scrollbar

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">
.fixed_header {<!--   w w w.ja v a2  s  .c  o  m-->
   table-layout:fixed;
   border-collapse:collapse;
}

.fixed_header td:nth-child(1), th:nth-child(1) {
   min-width:100px;
}

.fixed_header thead tr {
   display:block;
   position:relative;
}

.fixed_header tbody {
   height:61px;
   display:block;
   overflow:auto;
}
</style> 
 </head> 
 <body> 
  <table class="fixed_header"> 
   <thead> 
    <tr> 
     <th>Lorem </th> 
     <th>Lorem ipsum d</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
    <tr> 
     <td>L</td> 
     <td>Lor</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials