Solution 1 :

Please update your table style as below

table {
  width: 100%;
}

table, td {
  border-collapse: collapse;
  border: 1px solid #000;
}

thead {
  display: table; 
  width: calc(100% - 17px); 
}

tbody {
  display: block; 
  max-height: 200px; 
  overflow-y: scroll;
}

th, td {
  padding: 5px;
  word-break: break-all; 
}

tr {
  display: table; 
  width: 100%;
  box-sizing: border-box; 
}

td {
  text-align: center;
  border-bottom: none;
  border-left: none;
}

tr th:first-child,
tr td:first-child {
  width: 100px;
}

Problem :

I am working in Angular Project but stuck in a design Issue

I am want to scroll the body of the table making body header fixed

I tried to do the at but not able to scroll just table body

My code and design is ready I have put it in below link –

https://stackblitz.com/edit/angular-x8c89j?file=src%2Fapp%2Fapp.component.html

Comments

Comment posted by Freeze the top row for an html table only (Fixed Table Header Scrolling)

Does this answer your question?

By