问题
I am using "@angular/core": "2.4.10" and "@angular/material": "2.0.0-beta.2". I have installed flex-layout using npm. I want to design responsive grid with cards. I am using md-grid-list and md-card. How do I use flex layout with md-card or md-grid-list. The grid and the card should be responsive according to the window/screen size. Expected result: As soon as I decrease the screen size, the number of columns should be reduced and when the screen size is big the number of columns should increase without overlapping the contents in the card.
回答1:
Here is the sample code which might be helpful Angular 2 material and flex-layout alignement This sample code worked for me.
<md-grid-list cols="4" rowHeight="250px" gutterSize="20px">
<md-grid-tile *ngFor="let data of myData">
<md-card [style.background]="'lightBlue'" [style.minHeight]="'100%'" >
<md-card-title>Your title here</md-card-title>
<md-card-content>
<h2>
any heading or content here
</h2>
</md-card-content>
</md-card>
</md-grid-tile>
</md-grid-list>
来源:https://stackoverflow.com/questions/43916702/how-to-use-flex-layout-along-with-md-card-in-the-grid-in-angular-2