-1

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

ANURAG RANJAN
  • 115
  • 2
  • 16
  • Does this answer your question? [Freeze the top row for an html table only (Fixed Table Header Scrolling)](https://stackoverflow.com/questions/8423768/freeze-the-top-row-for-an-html-table-only-fixed-table-header-scrolling) – לבני מלכה Jan 30 '20 at 11:42

1 Answers1

0

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;
}
Vishnu8429
  • 104
  • 6