0

I am trying to enter entries in table inputs for my inventory website. I want to freeze the headers of each column and tried doing it with this -> Freeze the top row for an html table only (Fixed Table Header Scrolling)

window.onload = function(){
  var to_show = '';
  for(var i = 1 ; i < 50 ; i++){
    to_show += '<tr><td><input type="text" autocomplete="off" id="product_name_'+ i +'" name="product_name_'+i+'" onkeyup="productSearch(this.value, '+i+')" tabindex="-1" style="font-size:larger;"></td>';
    to_show += '<td><input type="text" autocomplete="off" id="location_'+ i +'" name="location_'+ i +'" onkeyup="productSearch(this.value, '+ i +')" tabindex="-1" style="font-size:larger;"></td></tr>';
  }
  document.getElementById('addInside_tr_20').innerHTML = to_show;
}
@import url("https://fonts.googleapis.com/css?family=Montserrat:300,400|Oswald:200,300,400&display=swap");
:root {
  --purple-theme: #091428;
  --lightpurple-theme: #0f3a41;
  --gray-bg-heading: #b8b8b8;
  --gray-bg-sidebar: #dee3e7;
  --lightgreen-theme: #65ffce;
  --green-theme: #46b692;
  --red-theme: #f75b54;
}
/* width */
::-webkit-scrollbar {
  width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px grey;
  border-radius: 0px 0px 10px 10px;
  background: var(--lightpurple-theme);
}
/* Handle */
::-webkit-scrollbar-thumb {
  background: var(--green-theme);
  border-radius: 0 0 10px 10px;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: var(--lightgreen-theme);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
::-moz-selection {
  /* Code for Firefox */
  color: var(--purple-theme);
  background: var(--green-theme);
}
::selection {
  color: var(--purple-theme);
  background: var(--green-theme);
}
input:focus,
option:focus,
select:focus {
  outline-color: var(--lightgreen-theme);
}
body {
  height: 100%;
  background-repeat: no-repeat;
}
a {
  text-decoration: none;
}
table,
select,
input,
a {
  color: whitesmoke;
}
input {
  width: 100%;
  line-height: 5px;
  font-size: 10px;
}
input[type="text"],
input[type="url"],
input[type="number"] {
  height: 30px;
  border: 1px solid var(--green-theme);
  background-color: transparent;
  color: whitesmoke;
  font-size: 15px;
}
input[type="button"],
input[type="reset"],
input[type="submit"] {
  border: 1px solid var(--green-theme);
  background-color: var(--green-theme);
  color: var(--purple-theme);
  text-decoration-style: bold;
  font-size: 15px;
  border-radius: 0px 15px 15px 0px;
}

/* ------grid container------ */
input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
}
input[type="date"] {
  height: 100%;
}
.grid_container {
  display: grid;
  grid-template-columns: repeat(auto, 1fr);
  grid-gap: 10px;
  padding: 10px;
  margin: 0 auto;
  color: whitesmoke;
}
.grid {
  background-color: var(--purple-theme);
  border: 1px solid lightgrey;
  padding: 20px;
}
.inside > span {
  font-family: "Oswald", sans-serif;
  font-weight: 400;
  font-size: 18px;
}
.item1 {
  grid-column: 1 / 3;
}
.item2 {
  grid-column: 3 / 5;
}

.item3 {
  grid-column: 5 / 7;
}
.item4 {
  grid-column: 7 / 9;
}

.item5 {
  grid-column: 1 / 9;
}

.inside {
  padding: 0;
  padding-bottom: 10px;
  border: none;
}

.item2 {
  grid-column: 1 / 9;
  grid-row: 1 / 5;
}
.inside input[type="text"] {
  width: 200px;
}
.item2 select,
.item2 option {
  width: 100%;
  height: 30px;
  background-color: var(--purple-theme);
  border: 1px solid var(--green-theme);
  text-align: center;
}
.item2 select option {
  background: var(--purple-theme);
}
.item2 table {
  width: 100%;
  text-align: center;
  margin-top: 20px;
  font-size: 20px;
}
.details table:nth-child(1) {
  margin-top: -20px;
}
.details {
  margin-top: -20px;
}
.item2 th {
  background-color: var(--green-theme);
  color: var(--purple-theme);
  padding: 15px;
}
.item2 a {
  text-decoration: underline;
}

/* main edit here start */
                      #text-area td:nth-child(1) {
                        width: 80%;
                      }
                      #text-area td:nth-child(2) {
                        width: 20%;
                      }
                      #text-area thead th:nth-child(1) {
                        width: 80%;
                      }
                      #text-area thead th:nth-child(2) {
                        width: 20%;
                      }

                      #text-area thead {
                        display: block;
                      }
                      #text-area tbody {
                        height: 440px;
                        display: block;
                        overflow: auto;
                        width: 100%;
                      }
                      #text-area input {
                        width: 100%;
                      }

                      #text-area input {
                        border: none;
                      }
                      #text-area {
                        border: 1px solid var(--green-theme);
                      }
                      #text-area tr:nth-child(2n + 1) {
                        background: var(--lightpurple-theme);
                      }
                      #text-area td:nth-child(4) {
                        border-right: none;
                      }
                      #text-area td {
                        border-right: 1px solid var(--green-theme);
                      }
/* main edit here ends */
.item2 .inside table * {
  padding-bottom: 20px;
}

.suggestion {
  position: absolute;
  background-color: var(--purple-theme);
  font-size: smaller;
  cursor: pointer;
}
.suggestion_i:hover {
  color: var(--purple-theme);
  background-color: var(--green-theme);
}
.suggestion_i {
  cursor: pointer;
  text-align: center;
  text-justify: center;
  padding: 10px 10px -5px 10px;
}
#sorted_div {
  background-color: var(--purple-theme);
  /*position:absolute;*/
  top: 123px;
}
#sorted_div tr:nth-child(2n + 1) {
  background: var(--lightpurple-theme);
}
        <div class="grid_container">
          <div class="grid item2">
            <div class="inside" id="topTableID">
              <form action="php/invoiceFetch.php" method="post" enctype="multipart/form-data" id='myForm' onkeypress="return event.keyCode != 13;">
                <table>
                  <tr>
                    <td><label for="">Location :</label></td>
                    <td><input type="text" autocomplete="off" name="invoice_name" id="invoice_name" onchange="invoiceSpliter()" onkeyup="customerSearch(this.value)" style="width: 500;"></td>
                    <td><label>Product Suggestion : </label></td>
                    <td>
                      <div id="product_suggestion" class="suggestion"></div>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <div id="suggestion" class="suggestion"></div>
                    </td>
                    <td></td>
                    <td></td>
                  </tr>
                </table>
            </div>

            <div class="details">
              <table id="text-area">
                <thead>
                  <tr>
                    <th><label>Product Name</label></th>
                    <th><label>Current Locations</label></th>
                  </tr>
                </thead>
                <tbody id="addInside_tr_20">
                    <!--there will be some rows added here -->
                </tbody>
              </table>
              <table>
                <tr>
                  <td><input type="reset" value="Reset" tabindex="-1"></td>
                  <td><input type="button" onclick="document.getElementById('myModal').style.display = 'block';" value="Submit"></td>
                </tr>
              </table>
              </form>
            </div>
          </div>
        </div>

You can check the code on [codepen]{https://codepen.io/zaidi2293/pen/WNwmJrP} (Ignore most of the css as they are just to replicate what I had so that I don't miss something out)


(Sorry for the extensive code length) The Problem is the "thead" is not aligned with "tbody" as in column perspective because of overflow in vertical direction. I've asked this question before but that doesn't seem to work for me. Also, there will be some more columns added in the future. No custom size width answers please

Saad Saiyed
  • 126
  • 1
  • 7
  • Please see how (and why) to create a [MRE] with the *minimum* code required to reproduce the problem so we can help. Extra code just complicates the issue and can even add more problems, and it also makes it much easier for us to understand your code so we are better able to help. – FluffyKitten Sep 26 '20 at 14:28

1 Answers1

0

You may take a look at position:sticky to preserve the integrity of the table-layout (no display reset).

the scroll bar has to come from the parent container

window.onload = function() {
  var to_show = '';
  for (var i = 1; i < 50; i++) {
    to_show += '<tr><td><input type="text" autocomplete="off" id="product_name_' + i + '" name="product_name_' + i + '" onkeyup="productSearch(this.value, ' + i + ')" tabindex="-1" style="font-size:larger;"></td>';
    to_show += '<td><input type="text" autocomplete="off" id="location_' + i + '" name="location_' + i + '" onkeyup="productSearch(this.value, ' + i + ')" tabindex="-1" style="font-size:larger;"></td></tr>';
  }
  document.getElementById('addInside_tr_20').innerHTML = to_show;
}
@import url("https://fonts.googleapis.com/css?family=Montserrat:300,400|Oswald:200,300,400&display=swap");
:root {
  --purple-theme: #091428;
  --lightpurple-theme: #0f3a41;
  --gray-bg-heading: #b8b8b8;
  --gray-bg-sidebar: #dee3e7;
  --lightgreen-theme: #65ffce;
  --green-theme: #46b692;
  --red-theme: #f75b54;
}


/* width */

::-webkit-scrollbar {
  width: 10px;
}


/* Track */

::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px grey;
  border-radius: 0px 0px 10px 10px;
  background: var(--lightpurple-theme);
}


/* Handle */

::-webkit-scrollbar-thumb {
  background: var(--green-theme);
  border-radius: 0 0 10px 10px;
}


/* Handle on hover */

::-webkit-scrollbar-thumb:hover {
  background: var(--lightgreen-theme);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::-moz-selection {
  /* Code for Firefox */
  color: var(--purple-theme);
  background: var(--green-theme);
}

::selection {
  color: var(--purple-theme);
  background: var(--green-theme);
}

input:focus,
option:focus,
select:focus {
  outline-color: var(--lightgreen-theme);
}

body {
  height: 100%;
  background-repeat: no-repeat;
}

a {
  text-decoration: none;
}

table,
select,
input,
a {
  color: whitesmoke;
}

input {
  width: 100%;
  line-height: 5px;
  font-size: 10px;
}

input[type="text"],
input[type="url"],
input[type="number"] {
  height: 30px;
  border: 1px solid var(--green-theme);
  background-color: transparent;
  color: whitesmoke;
  font-size: 15px;
}

input[type="button"],
input[type="reset"],
input[type="submit"] {
  border: 1px solid var(--green-theme);
  background-color: var(--green-theme);
  color: var(--purple-theme);
  text-decoration-style: bold;
  font-size: 15px;
  border-radius: 0px 15px 15px 0px;
}


/* ------grid container------ */

input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
}

input[type="date"] {
  height: 100%;
}

.grid_container {
  display: grid;
  grid-template-columns: repeat(auto, 1fr);
  grid-gap: 10px;
  padding: 10px;
  margin: 0 auto;
  color: whitesmoke;
}

.grid {
  background-color: var(--purple-theme);
  border: 1px solid lightgrey;
  padding: 20px;
}

.inside>span {
  font-family: "Oswald", sans-serif;
  font-weight: 400;
  font-size: 18px;
}

.item1 {
  grid-column: 1 / 3;
}

.item2 {
  grid-column: 3 / 5;
}

.item3 {
  grid-column: 5 / 7;
}

.item4 {
  grid-column: 7 / 9;
}

.item5 {
  grid-column: 1 / 9;
}

.inside {
  padding: 0;
  padding-bottom: 10px;
  border: none;
}

.item2 {
  grid-column: 1 / 9;
  grid-row: 1 / 5;
}

.inside input[type="text"] {
  width: 200px;
}

.item2 select,
.item2 option {
  width: 100%;
  height: 30px;
  background-color: var(--purple-theme);
  border: 1px solid var(--green-theme);
  text-align: center;
}

.item2 select option {
  background: var(--purple-theme);
}

.item2 table {
  width: 100%;
  text-align: center;
  margin-top: 20px;
  font-size: 20px;
}

.item2 th {
  background-color: var(--green-theme);
  color: var(--purple-theme);
  padding: 15px;
}

.item2 a {
  text-decoration: underline;
}


/* main edit here start */

.details {
  overflow: auto;
  height: 440px;
}
.details table{margin-top:0;}
#text-area td:nth-child(1) {
  width: 80%;
}

#text-area td:nth-child(2) {
  width: 20%;
}

#text-area thead th:nth-child(1) {
  width: 80%;
}

#text-area thead th:nth-child(2) {
  width: 20%;
}

#text-area thead {
  position: sticky;
  top: 4px;
  box-shadow: 0 0 0 2px #091428, 0 -2px 0  2px #46b692;
}

#text-area tbody {}

#text-area input {
  width: 100%;
}

#text-area input {
  border: none;
}

#text-area {
  border: 1px solid var(--green-theme);
}

#text-area tr:nth-child(2n+1) {
  background: var(--lightpurple-theme);
}

#text-area td:nth-child(4) {
  border-right: none;
}

#text-area td {
  border-right: 1px solid var(--green-theme);
}


/* main edit here ends */

.item2 .inside table * {
  padding-bottom: 20px;
}

.suggestion {
  position: absolute;
  background-color: var(--purple-theme);
  font-size: smaller;
  cursor: pointer;
}

.suggestion_i:hover {
  color: var(--purple-theme);
  background-color: var(--green-theme);
}

.suggestion_i {
  cursor: pointer;
  text-align: center;
  text-justify: center;
  padding: 10px 10px -5px 10px;
}

#sorted_div {
  background-color: var(--purple-theme);
  /*position:absolute;*/
  top: 123px;
}

#sorted_div tr:nth-child(2n+1) {
  background: var(--lightpurple-theme);
}
<div class="grid_container">
  <div class="grid item2">
    <div class="inside" id="topTableID">
      <form action="php/invoiceFetch.php" method="post" enctype="multipart/form-data" id='myForm' onkeypress="return event.keyCode != 13;">
        <table>
          <tr>
            <td><label for="">Location :</label></td>
            <td><input type="text" autocomplete="off" name="invoice_name" id="invoice_name" onchange="invoiceSpliter()" onkeyup="customerSearch(this.value)" style="width: 500;"></td>
            <td><label>Product Suggestion : </label></td>
            <td>
              <div id="product_suggestion" class="suggestion"></div>
            </td>
          </tr>
          <tr>
            <td>
              <div id="suggestion" class="suggestion"></div>
            </td>
            <td></td>
            <td></td>
          </tr>
        </table>
    </div>

    <div class="details">
      <table id="text-area">
        <thead>
          <tr>
            <th><label>Product Name</label></th>
            <th><label>Current Locations</label></th>
          </tr>
        </thead>
        <tbody id="addInside_tr_20">
          <!--there will be some rows added here -->
        </tbody>
      </table>
      <table>
        <tr>
          <td><input type="reset" value="Reset" tabindex="-1"></td>
          <td><input type="button" onclick="document.getElementById('myModal').style.display = 'block';" value="Submit"></td>
        </tr>
      </table>
      </form>
    </div>
  </div>
</div>

From your current code , we can be inspired from How to set tbody height with overflow scroll and do

tr {
  display:table;
  width:100%;
}
thead {
  padding-right:1.2em;
}

.selector:not(*:root), thead {
padding-right: 10px;/* because you set a 10px scrollbar for chrome */
}
thead tr {
  box-shadow:0px -2px  var(--purple-theme),  1px -2px  var(--green-theme)
}

window.onload = function() {
  var to_show = '';
  for (var i = 1; i < 50; i++) {
    to_show += '<tr><td><input type="text" autocomplete="off" id="product_name_' + i + '" name="product_name_' + i + '" onkeyup="productSearch(this.value, ' + i + ')" tabindex="-1" style="font-size:larger;"></td>';
    to_show += '<td><input type="text" autocomplete="off" id="location_' + i + '" name="location_' + i + '" onkeyup="productSearch(this.value, ' + i + ')" tabindex="-1" style="font-size:larger;"></td></tr>';
  }
  document.getElementById('addInside_tr_20').innerHTML = to_show;
}
@import url("https://fonts.googleapis.com/css?family=Montserrat:300,400|Oswald:200,300,400&display=swap");
:root {
  --purple-theme: #091428;
  --lightpurple-theme: #0f3a41;
  --gray-bg-heading: #b8b8b8;
  --gray-bg-sidebar: #dee3e7;
  --lightgreen-theme: #65ffce;
  --green-theme: #46b692;
  --red-theme: #f75b54;
}


/* width */

::-webkit-scrollbar {
  width: 10px;
}


/* Track */

::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px grey;
  border-radius: 0px 0px 10px 10px;
  background: var(--lightpurple-theme);
}


/* Handle */

::-webkit-scrollbar-thumb {
  background: var(--green-theme);
  border-radius: 0 0 10px 10px;
}


/* Handle on hover */

::-webkit-scrollbar-thumb:hover {
  background: var(--lightgreen-theme);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::-moz-selection {
  /* Code for Firefox */
  color: var(--purple-theme);
  background: var(--green-theme);
}

::selection {
  color: var(--purple-theme);
  background: var(--green-theme);
}

input:focus,
option:focus,
select:focus {
  outline-color: var(--lightgreen-theme);
}

body {
  height: 100%;
  background-repeat: no-repeat;
}

a {
  text-decoration: none;
}

table,
select,
input,
a {
  color: whitesmoke;
}

input {
  width: 100%;
  line-height: 5px;
  font-size: 10px;
}

input[type="text"],
input[type="url"],
input[type="number"] {
  height: 30px;
  border: 1px solid var(--green-theme);
  background-color: transparent;
  color: whitesmoke;
  font-size: 15px;
}

input[type="button"],
input[type="reset"],
input[type="submit"] {
  border: 1px solid var(--green-theme);
  background-color: var(--green-theme);
  color: var(--purple-theme);
  text-decoration-style: bold;
  font-size: 15px;
  border-radius: 0px 15px 15px 0px;
}


/* ------grid container------ */

input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
}

input[type="date"] {
  height: 100%;
}

.grid_container {
  display: grid;
  grid-template-columns: repeat(auto, 1fr);
  grid-gap: 10px;
  padding: 10px;
  margin: 0 auto;
  color: whitesmoke;
}

.grid {
  background-color: var(--purple-theme);
  border: 1px solid lightgrey;
  padding: 20px;
}

.inside>span {
  font-family: "Oswald", sans-serif;
  font-weight: 400;
  font-size: 18px;
}

.item1 {
  grid-column: 1 / 3;
}

.item2 {
  grid-column: 3 / 5;
}

.item3 {
  grid-column: 5 / 7;
}

.item4 {
  grid-column: 7 / 9;
}

.item5 {
  grid-column: 1 / 9;
}

.inside {
  padding: 0;
  padding-bottom: 10px;
  border: none;
}

.item2 {
  grid-column: 1 / 9;
  grid-row: 1 / 5;
}

.inside input[type="text"] {
  width: 200px;
}

.item2 select,
.item2 option {
  width: 100%;
  height: 30px;
  background-color: var(--purple-theme);
  border: 1px solid var(--green-theme);
  text-align: center;
}

.item2 select option {
  background: var(--purple-theme);
}

.item2 table {
  width: 100%;
  text-align: center;
  margin-top: 20px;
  font-size: 20px;
}

.details table:nth-child(1) {
  margin-top: -20px;
}

.details {
  margin-top: -20px;
}

.item2 th {
  background-color: var(--green-theme);
  color: var(--purple-theme);
  padding: 15px;
}

.item2 a {
  text-decoration: underline;
}


/* main edit here start */

#text-area td:nth-child(1) {
  width: 80%;
}

#text-area td:nth-child(2) {
  width: 20%;
}

#text-area thead th:nth-child(1) {
  width: 80%;
}

#text-area thead th:nth-child(2) {
  width: 20%;
}

#text-area thead {
  display: block;
}

#text-area tbody {
  height: 440px;
  display: block;
  overflow: auto;
  width: 100%;
}

#text-area input {
  width: 100%;
}

#text-area input {
  border: none;
}

#text-area {
  border: 1px solid var(--green-theme);
}

#text-area tr:nth-child(2n+1) {
  background: var(--lightpurple-theme);
}

#text-area td:nth-child(4) {
  border-right: none;
}

#text-area td {
  border-right: 1px solid var(--green-theme);
}


/* main edit here ends */

.item2 .inside table * {
  padding-bottom: 20px;
}

.suggestion {
  position: absolute;
  background-color: var(--purple-theme);
  font-size: smaller;
  cursor: pointer;
}

.suggestion_i:hover {
  color: var(--purple-theme);
  background-color: var(--green-theme);
}

.suggestion_i {
  cursor: pointer;
  text-align: center;
  text-justify: center;
  padding: 10px 10px -5px 10px;
}

#sorted_div {
  background-color: var(--purple-theme);
  /*position:absolute;*/
  top: 123px;
}

#sorted_div tr:nth-child(2n+1) {
  background: var(--lightpurple-theme);
}


/* update / overwrite */
* {box-sizing:border-box}

tr {
  display: table;
  width: 100%;
}

thead {
  padding-right: 1.05em;
}

.selector:not(*:root), thead {
    padding-right: 10px;
  }
thead tr {
  box-shadow: 1px -2px var(--purple-theme), 2px -2px var(--green-theme)
}
<div class="grid_container">
  <div class="grid item2">
    <div class="inside" id="topTableID">
      <form action="php/invoiceFetch.php" method="post" enctype="multipart/form-data" id='myForm' onkeypress="return event.keyCode != 13;">
        <table>
          <tr>
            <td><label for="">Location :</label></td>
            <td><input type="text" autocomplete="off" name="invoice_name" id="invoice_name" onchange="invoiceSpliter()" onkeyup="customerSearch(this.value)" style="width: 500;"></td>
            <td><label>Product Suggestion : </label></td>
            <td>
              <div id="product_suggestion" class="suggestion"></div>
            </td>
          </tr>
          <tr>
            <td>
              <div id="suggestion" class="suggestion"></div>
            </td>
            <td></td>
            <td></td>
          </tr>
        </table>
    </div>

    <div class="details">
      <table id="text-area">
        <thead>
          <tr>
            <th><label>Product Name</label></th>
            <th><label>Current Locations</label></th>
          </tr>
        </thead>
        <tbody id="addInside_tr_20">
          <!--there will be some rows added here -->
        </tbody>
      </table>
      <table>
        <tr>
          <td><input type="reset" value="Reset" tabindex="-1"></td>
          <td><input type="button" onclick="document.getElementById('myModal').style.display = 'block';" value="Submit"></td>
        </tr>
      </table>
      </form>
    </div>
  </div>
</div>
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
  • Thanks a lot for this suggestion but I need the column's headers (th) to be frozen on top. – Saad Saiyed Sep 26 '20 at 14:43
  • @SaadSaiyed , okay, you will probably need javascript to reset width to each columns , once display is reset on table/table children, the table-layout is not avalaible anymore. I'll delete my answer later unless you might need it later as an alternative ;) – G-Cyrillus Sep 26 '20 at 14:50
  • thanks again @G-Cyrillus but what you said about resetting column width in javascript, just jumped over my head. Can you please elaborate. Thanks again for helping me with the same problem. And yeah I'll go with this approach if nothing works. – Saad Saiyed Sep 26 '20 at 15:04
  • 1
    @SaadSaiyed i added a second snippet using your own code with just a very little CSS update at the end of yours to overwrite it , the sample stands right before the snippet, minding also the custom scrollbar for chrome , since your code did set column's width. would that be a better hint for you ? – G-Cyrillus Sep 26 '20 at 19:29
  • thanks, that was helpful but I was simplifying what I actually had implemented to make others understand my problem. You see I've just added two-column for the example but in the actual project, the table has 11 columns sizing from 50px to 880px. As of now, I'm actually over this implementation and I have tried using a different approach that has no sticky columns. The suggestion cleared that it has to be padded from the right to get the correct width from the calculation. That was so helpful. Thanks again. (I would definitely upvote this answer if it works for all the cases) – Saad Saiyed Oct 03 '20 at 18:58
  • @SaadSaiyed - the padding option works no matter the width, the scrollbar has always the same width and known . here if this is what bothers you , then https://stackoverflow.com/questions/23989463/how-to-set-tbody-height-with-overflow-scroll/23989771#23989771 is a very similar question and for the chrome custom scrollbar, way to deal with, stands here. Once you solved your issue, you can answer your own question and pick it as the right answer. ;) Can be usefull to anyone else like you. – G-Cyrillus Oct 03 '20 at 20:34