How to give fixed height to Angular Material Table

拟墨画扇 提交于 2020-08-04 03:41:10

问题


I have an angular material table(10 rows)for which i want to fix the height to 300px(Vertical scroll should be used to see the extra rows). When i give height in the styles to 300px it is not having any effect. The contents of the table are going out of the height given.

See the link for the image.

I want to have two tables one below another and i want to give them equal height 50%. The first table itself taking 10 rows height.

Angular Material Table


回答1:


I use a wrapper div with class

<div class="table-container">
   <table mat-table [dataSource]=.....>
   </table>
</div>

and this is the class

.table-container {
  margin-top: 10px;
  max-height: 300px;
  overflow: auto;
}



回答2:


Try this one in css file

table tr.mat-row {
  height: 300px;
}


来源:https://stackoverflow.com/questions/51674711/how-to-give-fixed-height-to-angular-material-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!