This is my table in Html:
<div class="outer">
<div class="inner">
<table>
<tr>
<th >Header A</th>
<td style="position:absolute; " >col 1 - A</td>
<td >col 2 - A (COVER CONTENT)</td>
<td >col 3 - A</td>
<td >col 4 - A</td>
<td >col 5 - A</td>
<td >col 6 - A</td>
<td >col 7 - A</td>
<td >col 8 - A</td>
</tr>
<tr>
<th>Header B</th>
<td >col 1 - B</td>
<td>col 2 - B</td>
<td>col 3 - B</td>
<td>col 4 - B</td>
<td>col 5 - B</td>
<td>col 6 - B</td>
<td>col 7 - B</td>
<td>col 8 - B</td>
</tr>
<tr>
<th>Header C</th>
<td>col 1 - C</td>
<td>col 2 - C</td>
<td>col 3 - C</td>
<td>col 4 - C</td>
<td>col 5 - C</td>
<td>col 6 - C</td>
<td>col 7 - C</td>
<td>col 8 - C</td>
</tr>
</table>
</div>
</div>
and CSS:
<style>
table {
table-layout: fixed;
width: 100%;
*margin-left: -100px;/*ie7*/
}
td, th {
vertical-align: top;
border-top: 1px solid #ccc;
padding:10px;
width:100px;
}
th {
position:absolute;
left:0;
width:100px;
}
.outer {position:relative}
.inner {
overflow-x:scroll;
overflow-y:visible;
width:400px;
margin-left:100px;
}
</style>
I worked good when keeping tag <th>
freezing, but I want to keep visible tag <td>
with content "col 1 - A" by adding style="positon:absolute;"
into <td>
tag. it keep but the content of the other <td>
cover it, that means "col 2 - A (COVER CONTENT)" and "col 1 - A" cover each other in the same cell.
p.s.: If I have tag <td rowspan="2">
how do I set position:absolute in this tag? I tried to add it into <td>
but it just keep only one row....
Need help....
Try this
<td ><div style="position:fixed;background-color: white;width:inherit" >col 1 - A</div></td>
Here is demo: JSFIDDLE