私はMD-グリッドタイル内のネストされたMD-カードを使用して、それを達成することができています。問題は.mat-figureのプロパティ "align-items:center"でした。ここで
**Component:**
import { Component, OnInit } from '@angular/core';
@Component({
templateUrl: './abc.component.html',
styleUrls: ['./abc.component.css']
})
export class AbcComponent implements OnInit {
ngOnInit() {
}
tiles = [
{text: 'One', cols: 1, rows: 1, color: 'lightblue'},
{text: 'Two', cols: 1, rows: 1, color: 'lightgreen'},
{text: 'Three', cols: 1, rows: 1, color: 'lightpink'},
{text: 'Four', cols: 1, rows: 1, color: '#DDBDF1'},
{text: 'Five', cols: 1, rows: 1, color: '#DDBDF1'},
{text: 'Six', cols: 1, rows: 1, color: '#DDBDF1'},
];
}
**abc.component.html file content:**
<md-grid-list cols="3">
<md-grid-tile
*ngFor="let tile of tiles"
[colspan]="tile.cols"
[rowspan]="tile.rows"
[style.background]="tile.color">
<md-card class="square_board">HI</md-card>
</md-grid-tile>
</md-grid-list>
**abc.component.css file content:**
.square_board{
margin: 10px;
width: 100%;
}
::ng-deep md-grid-tile.mat-grid-tile .mat-figure {
align-items: initial; /*vertical alignment*/
}
結果である: はここに私のソリューションです
このアプローチのbenifitは、我々はカードの間隔と配置を気にする必要はありませんということです。
この回答を確認すると、おそらくそれが役に立ちます。 https://stackoverflow.com/questions/44995971/creating-grid-of-cards-dynamically-using-angular-material-2/45856258#45856258 –