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,438
  • 68
  • 55
  • 126
user1856596
  • 6,571
  • 9
  • 39
  • 60

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,091
  • 4
  • 44
  • 55
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,801
  • 8
  • 26
  • 45