JSFiddle - React, Tailwind, and code Playground

by Ayyappan Sakthivadivel

HTML

<div class="tbl">
  <div class="table-area">
    <table class="responsive-table table">
      <thead>
        <tr>
          <th><input type="checkbox"> First name</th>
          <th>Last name</th>
          <th>Points</th>
          <th>Content</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><input type="checkbox">  Jill</td>
          <td>Smith</td>
          <td>50</td>
          <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
        </tr>
        <tr>
          <td><input type="checkbox">  Eve</td>
          <td>Jackson</td>
          <td>94</td>
          <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</td>
        </tr>
        <tr>
          <td><input type="checkbox">  Jill</td>
          <td>Smith</td>
          <td>50</td>
          <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
        </tr>
        <tr>
          <td><input type="checkbox">  Eve</td>
          <td>Jackson</td>
          <td>94</td>
          <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</td>
        </tr>
        <tr>
          <td><input type="checkbox">  Jill</td>
          <td>Smith</td>
          <td>50</td>
          <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
        </tr>
        <tr>
          <td><input type="checkbox">  Eve</td>
          <td>Jackson</td>
          <td>94</td>
          <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</td>
        </tr>
        <tr>
          <td><input type="checkbox">  Jill</td>
          <td>Smith</td>
          <td>50</td>
          <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>
        </tr>
        <tr>
          <td><input type="checkbox">  Eve</td>
          <td>Jackson</td>
          <td>94</td>
          <td>Lorem Ipsum has been the industry's standard...

CSS

body{
  margin: 0;
}

.tbl{
  padding: 20px;
}
.table-area {
  height: 300px;
  position: relative;
  z-index: 0;
  overflow-y: auto;

}

table.responsive-table {
  display: table;
  /* required for table-layout to be used (not normally necessary; included for completeness) */
  table-layout: fixed;
  /* this keeps your columns with fixed with exactly the right width */
  width: 100%;
  /* table must have width set for fixed layout to work as expected */
  height: 100%;
}

table.responsive-table thead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 50px;
  line-height: 3em;
  background: #eee;
  table-layout: fixed;
  display: table;
}

table.responsive-table th {
  background: #eee;
    margin: 20px;
}

table.responsive-table td {
  line-height: 2em;
}

table.responsive-table tr > td,
table.responsive-table th {
  text-align: left;
}