I want to use mat-grid-list
to create a grid list layout in which each mat-grid-tile
contains a mat-card
that fills the entire tile regardless of the card's content. Most of the cards need to occupy multiple rows and/or columns. So far I haven't been able to get it working.
Things I have tried:
width
and height
to 100% using the selector mat-card
. This causes each card to fill the entire screen rather than just the mat-grid-tile
that contains the card.width
and height
to 100% using the selector mat-grid-tile > mat-card
. This has the same effect as not having a selector at all, as the cards just remain centered within their grid tiles wrapped to the sizes of the their respective contents.flex
, layout-wrap
, and layout-fill
are not available to me, probably because the sample code is using Angular 2 rather than 4.Edit: It looks like I misunderstood the results of the first attempt listed above. The cards actually fill just the mat-grid-tile
s but their surrounding shadows get cut off by the tiles' boundaries.
You have to set the cols attribute of the mat-grid-list dynamically depending on the screen width. You'd have to decide on which width breakpoint will the mat-grid-list render the 1-column version. Hope this helps!
gutterSize. Defines the size of the grid list's gutter in a form of pixels, and always the default value will be 1px.
The <mat-card> is a container for the content that can be used to insert the media, text & action in context to the single subject. The basic requirement for design the card is only an <mat-card> element that has some content in it, that will be used to build simple cards.
I am not sure what exactly is not working for you, but I have just recreated your scenario in stackblitz, and used the following style for mat-card
:
mat-card {
width: calc(100% - 70px);
height: calc(100% - 70px);
}
Here's the stackblitz link: https://stackblitz.com/edit/angular-eqs6cp?file=app%2Fapp.component.css
And just in case you are worried (as I was) about the support for css calc()
here's the supported browsers and versions: http://caniuse.com/#feat=calc
(answer was updated based on first comment)
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