我正在尝试在表格的顶部和最左边创建一个具有固定变量的2D表格。我已经添加了水平和垂直标题,但我不太确定如何解决这些问题,以便观看者可以滚动浏览数据。如何在css中创建固定的垂直和水平表格?
CSS + HTML:
.fixed-tables {
position: relative background: white;
}
.fixed-tables th {
position: absolute;
background: white;
}
<table class="table fixed-tables">
<thead>
<tr>
<th></th>
<th>Hor. Header 1</th>
<th>Hor. Header 2</th>
<th>Hor. Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<th>Ver. Header 1</th>
<td>(null)</td>
<td>(null)</td>
</tr>
<tr>
<th>Ver. Header 2</th>
<td>(null)</td>
<td>(null)</td>
</tr>
<tr>
<th>Ver. Header 3</th>
<td>(null)</td>
<td>(null)</td>
<td>(null)</td>
</tr>
</tbody>
</table>
这并不完全工作,因为数据和头互相重叠。任何意见是极大的赞赏。
请向我们提供您的相关的HTML代码,以及使我们可以帮助更容易地 –
对不起!我添加了我的html – newsharepointuser101
[可修改头文件的CSS-Scrollable Table]的可能副本(https://stackoverflow.com/questions/11891065/css-only-scrollable-table-with-fixed-headers) –