简体   繁体   English

通知 mat-table 它应该扩展以适合 mat-cells?

[英]Informing the mat-table that it should expand to fit the mat-cells?

I've increased the width of mat-cell elements like this:我增加了这样的mat-cell元素的宽度:

.mat-cell {
  min-width: 8rem;
}

This causes the cells total width to expand beyond the viewport width, which in turn causes it to overflow the mat-table .这会导致单元格的总宽度超出视口宽度,从而导致它溢出mat-table
How do we get the mat-table to dynamically increase its size to fit the cells?我们如何让mat-table动态增加其大小以适应单元格? Right now it looks like it only expands by default to the width of the viewport.现在看起来它默认只会扩展到视口的宽度。

Here's a stackblitz demo. 这是一个 stackblitz 演示。

This is one solution.这是一种解决方案。 It makes the table container scrollable.它使表容器可滚动。

Add overflow: auto ;添加overflow: auto

.mat-table { width: 100%; overflow: auto}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM