私のテーブルのヘッダーを修正したい。テーブルはスクロール可能なdiv内にあります。以下は私のコードです。以下はスクロール可能なdiv内に固定ヘッダーテーブルを作成するには?
<div id="table-wrapper">
<div id="table-scroll">
<table bgcolor="white" border="0" cellpadding="0" cellspacing="0" id="header-fixed" width="100%" overflow="scroll" class="scrollTable">
<thead>
<tr>
<th>Order ID</th>
<th>Order Date</th>
<th>Status</th>
<th>Vol Number</th>
<th>Bonus Paid</th>
<th>Reason for no Bonus</th>
</tr>
</thead>
<tbody>
<tr>
<td><%=snd.getOrderId()%></td>
<td><%=snd.getDateCaptured()%></td>
<td><%=snd.getOrderStatus()%></td>
<td>Data Not Available</td>
<td>Data Not Available</td>
<td>Data Not Available</td>
</tr>
</tbody>
</table>
</div>
</div>
私は上記のdivのために使用しています私のCSS、次のとおりです。このような何かをすることについてどのように
#table-wrapper {
position:relative;
}
#table-scroll {
height:250px;
overflow:auto;
margin-top:20px;
}
#table-wrapper table {
width:100%;
}
#table-wrapper table * {
background:white;
color:black;
}
#table-wrapper table thead th .text {
position:absolute;
top:-20px;
z-index:2;
height:20px;
width:35%;
border:1px solid red;
}
あなたが「のヘッダーを作るとはどういう意味ですかを私のテーブルは固定されましたか?スクロールダウンしても常に見えるはずですか? – Mario
@Mario正確にテーブルの一番上の行は常に表示されるべきです – Rohan
Iveは似たような質問に答えを追加しましたhttp://stackoverflow.com/questions/31433833/fix-table-header-at-top-of-scrollable- div/31434590#31434590 –