Angular 6+
Angular Material 6+
I want a single mat-grid-tile
to have lower height compare to other tiles. Trying to do this by setting [rowspan]=".3"
property. It does make the tile and it's content height smaller, but the space between this "smaller" tile and the next one is still as if the tile had [rowspan]="1"
. setting the next tile's [rowspan]=".7"
doesn't fix it - they still the same space of full height row each.
<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);
}
What is the correct way to do so / how to solve a problem described above?
03 Oct 2022 / 2 minutes to read. You can customize the row height of grid rows through the rowHeight property. The rowHeight property is used to change the row height of entire grid rows. In the below example, the rowHeight is set as '60px'.
Inside the <mat-grid-list> tag we need to use <mat-grid-tile tag for every item. We also have properties like cols and rowHeight which we can use for styling. cols property is used to display number of grids in a row. Once done with the above steps then serve or start the project.
gutterSize. Defines the size of the grid list's gutter in a form of pixels, and always the default value will be 1px. And we can also specify the ratio or rem(root em) value with it.
Solved by splitting rows into smaller. Increasing [rowspan]
and decreasing rowHeight
.
i.e.:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With