My table is similar to the one suggested by Eamon Nerbonne in how do I create an HTML table with fixed/frozen left column and scrollable body?. Its code can be found below.
By default, the table appear as 'scrolled: 0% 0%'
, i.e. scrolled to the top left (one can see the cell "AAAA" of row 1).
Question: How to make this table 'scrolled: 0% 100%'
by default, i.e. that one can see the top right cell when the page is loaded (here cell "ZZZZ" of row 1) as shown in the picture below?
body {
font:16px Calibri;
}
div {
width: 600px;
overflow-x:scroll;
margin-left:5em;
overflow-y:visible;
padding-bottom:1px;
}
table {
border-collapse:separate;
border-top:
3px solid grey;
}
td, th {
margin:0;
border:3px solid grey;
border-top-width:0px;
white-space:nowrap;
}
.headcol {
position:absolute;
width:5em;
left:0;
top:auto;
border-right: 0px none black;
border-top-width:3px; /*only relevant for first row*/
margin-top:-3px; /*compensate for top border*/
}
.headcol:before {content: 'Row ';}
.long { background:yellow; letter-spacing:1em; }
<div>
<table>
<tr>
<th class="headcol">1</th>
<td class="long">AAAAA</td>
<td class="long">BBBBB</td>
<td class="long">CCCCC</td>
<td class="long">DDDDD</td>
<td class="long">EEEEE</td>
<td class="long">FFFFF</td>
<td class="long">GGGGG</td>
<td class="long">HHHHH</td>
<td class="long">.....</td>
<td class="long">XXXXX</td>
<td class="long">YYYYY</td>
<td class="long">ZZZZZ</td>
</tr>
<tr>
<th class="headcol">2</th>
<td class="long">AAAAA</td>
<td class="long">BBBBB</td>
<td class="long">CCCCC</td>
<td class="long">DDDDD</td>
<td class="long">EEEEE</td>
<td class="long">FFFFF</td>
<td class="long">GGGGG</td>
<td class="long">HHHHH</td>
<td class="long">.....</td>
<td class="long">XXXXX</td>
<td class="long">YYYYY</td>
<td class="long">ZZZZZ</td>
</tr>
<tr>
<th class="headcol">3</th>
<td class="long">AAAAA</td>
<td class="long">BBBBB</td>
<td class="long">CCCCC</td>
<td class="long">DDDDD</td>
<td class="long">EEEEE</td>
<td class="long">FFFFF</td>
<td class="long">GGGGG</td>
<td class="long">HHHHH</td>
<td class="long">.....</td>
<td class="long">XXXXX</td>
<td class="long">YYYYY</td>
<td class="long">ZZZZZ</td>
</tr>
<tr>
<th class="headcol">4</th>
<td class="long">AAAAA</td>
<td class="long">BBBBB</td>
<td class="long">CCCCC</td>
<td class="long">DDDDD</td>
<td class="long">EEEEE</td>
<td class="long">FFFFF</td>
<td class="long">GGGGG</td>
<td class="long">HHHHH</td>
<td class="long">.....</td>
<td class="long">XXXXX</td>
<td class="long">YYYYY</td>
<td class="long">ZZZZZ</td>
</tr>
</table>
</div>