make the some columns fixed and some scrollable of a table - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

make the some columns fixed and some scrollable of 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">
table {<!--  w w w  .  ja v a 2  s.  c  om-->
   border-collapse:collapse;
}

table, td, th {
   border:2px solid Chartreuse;
}

td {
   white-space:nowrap;
}

.first {
   position:absolute;
   width:41px;
   left:0;
   top:auto;
   background:red;
}

.second {
   position:absolute;
   width:41px;
   left:43px;
   top:auto;
   background:green;
}

.wrapper {
   width:501px;
   overflow-x:scroll;
   margin-left:81px;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <table> 
    <tbody> 
     <tr> 
      <td class="first">L</td> 
      <td class="second">Lo</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
     </tr> 
     <tr> 
      <td class="first">L</td> 
      <td class="second">Lo</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
     </tr> 
     <tr> 
      <td class="first">L</td> 
      <td class="second">Lo</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
     </tr> 
     <tr> 
      <td class="first">L</td> 
      <td class="second">Lo</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
      <td class="rest">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpa</td> 
     </tr> 
    </tbody> 
   </table> 
  </div>  
 </body>
</html>

Related Tutorials