.tableFixHead thead th { position: sticky; top: 0; }
.tableFixHead { overflow: auto; height: 100px; }
.tableFixHead thead th { position: sticky; top: 0; z-index: 1; }
/* Just common table stuff. Really. */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 16px; }
th { background:#eee; }
<div class="tableFixHead">
<table>
<thead>
<tr><th>TH 1</th><th>TH 2</th></tr>
</thead>
<tbody>
<tr><td>A1</td><td>A2</td></tr>
<tr><td>B1</td><td>B2</td></tr>
<tr><td>C1</td><td>C2</td></tr>
<tr><td>D1</td><td>D2</td></tr>
<tr><td>E1</td><td>E2</td></tr>
</tbody>
</table>
</div>
table tbody { display:block; max-height:450px; overflow-y:scroll; }
table thead, table tbody tr { display:table; width:100%; table-layout:fixed; }
Add table id="mainTable" then take this css
#mainTable>tbody {
display: block;
height: 400px;
overflow: auto;
}
#mainTable thead, tbody tr {
display: table;
width: 100%;
table-layout: fixed;
}
#mainTable thead {
width: calc( 100% - 1em );
}
Code Example |
---|
Css :: custom taxonomy pagination 404 |
Css :: using materialize css with react |
Css :: scss media query |
Css :: css noise filter |
Css :: Modify your placeholder |
Css :: css horizontal line around text |
Css :: This message is shown once a day. To disable it please create |
Css :: css text-decoration |
Css :: alert without page refresh |
Css :: flex-flow |
Css :: css grid column |
Css :: css animated background |
Css :: round corners of image css |
Css :: CSS logo left and navigation right |
Css :: variables scss |
Css :: border css dashed |
Css :: nibabel ValueError: w2 should be positive, but is |
Css :: time an element to disappear css |
Css :: html style input number buttons |
Css :: prefix in css |
Css :: Heart Shape Html And Css |
Css :: difference between html and css |
Css :: css make div one line |
Css :: col-md-6 bootstrap |
Css :: span size css |
Css :: css nesting |
Css :: remove required effect in css |
Css :: button active css |
Css :: display css |
Css :: Scrollbar inside a website |