我在rails工作,我有一张桌子,想要添加带有固定标题的水平和垂直滚动,详细信息如下:
这是my currenty code
:
body {
font:16px Calibri;
}
table {
border-collapse:separate;
border-top: 3px solid orange;
}
td {
margin:0;
border:1px solid grey;
border-top-width:0px;
white-space:nowrap;
}
div.second {
width: 600px;
overflow-x:scroll;
overflow-y:visible;
margin-left:5em;
padding-bottom:1px;
height: auto;
}
div.first {
width: auto;
overflow-y: scroll;
overflow-x: hidden;
height: 150px;
padding-bottom: 1px;
position: absolute;
left:0;
top:auto;
}
.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*/
background:grey;
}
.headrow {
position: absolute;
width:100px;
left: 5em;
}
.long {
background:yellow;
}
<div id="scroll-table">
<div class="first">
<div class="second">
<table>
<thead>
<tr>
<td class="headcol">1 - 1</td>
<div class="headrow">
<td>C1</td>
<td>C2</td>
<td>C3</td>
<td>C4</td>
<td>C5</td>
<td>C6</td>
<td>C7</td>
<td>C8</td>
</div>
</tr>
</thead>
<tbody>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr><tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr><tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr><tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
<tr>
<td class="headcol">1</td>
<div class="row-content">
<td class="long">TYUIOPAS</td>
<td class="long">WERTYUOP</td>
<td class="long">QWEIOPAS</td>
<td class="long">QWEFGHJK</td>
<td class="long">QWERTYUI</td>
<td class="long">OPASDFGH</td>
<td class="long">TYUIOPAS</td>
<td class="long">UIOPASDF</td>
</div>
</tr>
</tbody>
</table>
</div>
</div>
</div>
我认为需要使用javascript
你能帮我解决一下吗?
由于