Search
 
SCRIPT & CODE EXAMPLE
 

CSS

table fixed header

.tableFixHead thead th { position: sticky; top: 0; }
Comment

table fixed header

.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; }
Comment

table fixed header

<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>
Comment

table fixed header

table tbody { display:block; max-height:450px; overflow-y:scroll; }
table thead, table tbody tr { display:table; width:100%; table-layout:fixed; }
Comment

fixed table header css

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 );
    }
Comment

PREVIOUS NEXT
Code Example
Css :: background image size css 
Css :: sass calc with variable 
Css :: css background half one color the other half another color 
Css :: div scrollable content 
Css :: how to make border blur css 
Css :: smooth transition in and out css 
Css :: css dark filter over image 
Css :: inline style background image 
Css :: resize logo html css 
Css :: css device orientation 
Css :: css transform y 
Css :: antd css import 
Css :: make text not selectable html js css 
Css :: html align text anchor 
Css :: move button to right css 
Css :: make triangle using div 
Css :: css variables 
Css :: how to hide scrollbar css 
Css :: css text justify 
Css :: minmax in grid 
Css :: center div horizontally 
Css :: css media two conditions 
Css :: beige hex code 
Css :: autofit grid css 
Css :: mirror css a pseudo :after or :before 
Css :: import maxcdn.bootstrapcdn.com not in index.html in specific component file 
Css :: word ellipsis css 
Css :: line through in css 
Css :: ul li dot seprator 
Css :: css first of type 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =