0

Let's say this is the table:

<table>
    <tbody>
         <tr>
             <th>something goes here</th>
             <td>dkjfkldfjlfjs</td> 
             <td>dkjfkldfjlfjs 4234324</td>
             <td>dkjfkldfjlfjfdgfdggs</td>
         </tr>
    </tbody>
</table>

Is it somehow possible to only scroll the tds from from left to right but leave the th where it is? Like when you fix a column in Excel where only the first column (the th) is frozen and the rest (all tds) scrolls at once.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1856596
  • 7,027
  • 10
  • 41
  • 63
  • http://salzerdesign.com/blog/?p=191 – Salman A Feb 20 '14 at 12:46
  • 2
    here you can find some ideas : http://stackoverflow.com/questions/1312236/how-do-i-create-an-html-table-with-fixed-frozen-left-column-and-scrollable-body – Richa Feb 20 '14 at 12:50

2 Answers2

0

Yes. You can, just apply overflow-x:scroll; with a display:inline-block; to achieve what you are looking for.

WORKING DEMO

The CSS:

td {
    display: inline-block;
    overflow-x: scroll;
}

Hope this helps.

Nitesh
  • 15,425
  • 4
  • 48
  • 60
0

Fiddle demo : Demo

When apply scroll to tbody, it may collapse table design. you have to manually apply width on header.

Adding scroll div block, below css is enough

min-height:200px;
overflow:auto;

For more details please check this blog post

DRAJI
  • 1,829
  • 8
  • 26
  • 45