Angular 6+
Angular Material 6+
我希望单个mat-grid-tile
的高度要比其他图块低。通过设置[rowspan]=".3"
属性来尝试执行此操作。它确实使磁贴及其内容高度变小,但此“较小”的磁贴与下一个磁贴之间的空间仍然好像该磁贴具有[rowspan]="1"
。设置下一个图块的[rowspan]=".7"
不能解决问题-它们仍然是每个全高行的相同空间。
<mat-grid-list [cols]="6" rowHeight="16rem">
<mat-grid-tile [colspan]="2" [rowspan]="1">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
<mat-grid-tile [colspan]="4" [rowspan]="1">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
<mat-grid-tile [colspan]="6" [rowspan]=".3">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
<mat-grid-tile [colspan]="6" [rowspan]="1">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
</mat-grid-list>
.dashboard-card {
width: calc(100% - 60px);
height: calc(100% - 60px);
}
这样做的正确方法是什么/如何解决上述问题?
答案 0 :(得分:1)
通过将行分成较小的列来解决。增加[rowspan]
并减少rowHeight
。
即:
<mat-grid-list [cols]="6" rowHeight="4rem">
<mat-grid-tile [colspan]="2" [rowspan]="4">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
<mat-grid-tile [colspan]="6" [rowspan]="1">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
<mat-grid-tile [colspan]="6" [rowspan]="4">
<mat-card class="dashboard-card">
something
</mat-card>
</mat-grid-tile>
</mat-grid-list>