如何调整 angular mat-table header 高度?我正在处理的 table 有列组(主 header 和子 headers)

How to adjust angular mat-table header height ? The table I am working on has column groups(main header and sub headers)

我使用了 https://stackblitz.com/edit/angular-bklajw?file=app%2Ftable-basic-example.html 中的示例代码。 但是高度属性好像不行。有什么方法可以自定义 main header 和 subheader 的高度吗?

th.mat-header-cell, td.mat-cell {
    text-align: center;
    border: 1px solid #CCC;
    padding: 0 !important;
    height: 20px;
}

您的问题不在于 <td> 元素,而在于 <tr> 元素。 只需添加:

tr.mat-header-row{
   height: 20px !important;
 }