Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular material mat-grid-tile height

  • 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?

like image 252
user1935987 Avatar asked Oct 04 '18 22:10

user1935987


People also ask

What is rowHeight in angular?

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'.

How to create a grid in Angular Material?

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.

What is gutterSize in mat grid list?

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.


1 Answers

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> 
like image 88
user1935987 Avatar answered Oct 03 '22 08:10

user1935987