Chcę, aby nagłówek mojego stołu został naprawiony. Stolik znajduje się wewnątrz przewijanego elementu div. Poniżej znajduje się mój kod.Jak zrobić stały nagłówek tabeli wewnątrz scrollable 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>
Poniżej jest mój CSS, który używam w powyższym Gr:
#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;
}
Co masz na myśli przez „make nagłówek mój stół naprawiony "? Czy mimo przewijania w dół ma być zawsze widoczny? – Mario
@Mario dokładnie górny rząd tabeli powinien być zawsze widoczny – Rohan
Właśnie dodałem odpowiedź na podobne pytanie, które może pomóc http://stackoverflow.com/questions/31433833/fix-table-header-at-top-of-scrollable- div/31434590 # 31434590 –