Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fixed header and scrollable body in table in html angular

Tags:

html

angular

In Angular i have a table and it should be scrollable. But header should be fixed. but while scrolling header is not fixed. please help

like image 937
ruby Avatar asked Aug 17 '26 11:08

ruby


1 Answers

Well, the requirement seems to be you want a scrollable table body. Not sure if angular could makes things different anyhow in this case. Just to be sure, please see the fiddle at https://jsfiddle.net/hh6etg6s/ if this serves the purpose.

.tablediv {
  padding:20px;
}
table ,tr td{
    border:1px solid red
}
tbody {
    display:block;
    height:200px;
    overflow:auto;
}
thead, tbody tr {
    display:table;
    width:100%;
    table-layout:fixed;/* even columns width , fix width of table too*/
}
thead {
    width: calc( 100% - 1em )/* scrollbar is average 1em/16px width, remove it from thead width */
}
table {
    width:400px;
}
like image 72
Charu Maheshwari Avatar answered Aug 20 '26 01:08

Charu Maheshwari