I've a HTML table. I want to keep the first 10 columns of the table fixed and add the horizontal scroll bar to the rest of columns from table. For achieving this I tried many ways. But ultimately I had to use table inside a table, which I want to avoid. Can anyone help me in this regard without using table inside a table. For your reference I'm giving here the link of jsFiddle. If you need any further information I can provide you the same. Thanks in advance. Waiting for your replies. The jsFiddle link is as follows:
The HTML code is as follows:
<table id="outerTable">
<tr>
<td style="vertical-align:top;"><div>
<table class="fixed">
<tr>
<td class="cell">One</td>
<td class="cell">Two</td>
<td class="cell">Three</td>
<td class="cell">Four</td>
<td class="cell">Five</td>
<td class="cell">Six</td>
<td class="cell">Seven</td>
<td class="cell">Eight</td>
<td class="cell">Nine</td>
<td class="cell">Ten</td>
</tr>
<tr>
<td class="cell">One</td>
<td class="cell">Two</td>
<td class="cell">Three</td>
<td class="cell">Four</td>
<td class="cell">Five</td>
<td class="cell">Six</td>
<td class="cell">Seven</td>
<td class="cell">Eight</td>
<td class="cell">Nine</td>
<td class="cell">Ten</td>
</tr>
</table>
</div></td>
<td style="vertical-align:top;"><div style="width:230px; overflow-x:scroll;">
<table class="scrolling">
<tr>
<td class="cell">One</td>
<td class="cell">Two</td>
<td class="cell">Three</td>
<td class="cell">Four</td>
<td class="cell">Five</td>
<td class="cell">Six</td>
<td class="cell">Seven</td>
<td class="cell">Eight</td>
<td class="cell">Nine</td>
<td class="cell">Ten</td>
</tr>
<tr>
<td class="cell">One</td>
<td class="cell">Two</td>
<td class="cell">Three</td>
<td class="cell">Four</td>
<td class="cell">Five</td>
<td class="cell">Six</td>
<td class="cell">Seven</td>
<td class="cell">Eight</td>
<td class="cell">Nine</td>
<td class="cell">Ten</td>
</tr>
</table>
</div></td>
</tr>
</table>
You may use
div
andul
,li
instead oftable td tr
likeDemo
HTML
CSS
You can use thead for your fixed column and tbody for the scrolling block with the following CSS:
You will get something like that: DEMO