Emeric
Emeric

Reputation: 6925

mat-card's content not fitting mat-card

I'm building an Angular 7 / Material / Flex-layout app and I'm having difficulty getting mat-card with a mat-card-image responsive.

The mat-card-image is a square picture with max-width/max-height 160px.

Scheme of what I'm trying to achieve:

enter image description here

enter image description here

In red is the mat-card but as you can see the content isn't fitting the mat-card (the image should be resized).

I tried a lot of things but here is my current code:

HTML:

       <div fxLayout="column" fxLayoutAlign="center center" fxFlexFill>


            <mat-card>
                <mat-card-header fxLayoutAlign="center">
                    <mat-card-title style="margin-bottom: 0px;" >
                        foo
                    </mat-card-title>
                </mat-card-header>

                <img mat-card-image [src]="foo" style="margin-bottom: 0px;" layout-fill>

                <mat-card-content fxLayoutAlign="center" style="margin-top: 0px;">
                    foo
                </mat-card-content>

            </mat-card>

            <span></span>

        </div>

CSS:

mat-card {
    max-width: 160px;
    max-height: 100%;
    padding-top: 0px;
    padding-bottom: 0px;
    box-sizing: border-box;
}

How to achieve that ?

Upvotes: 0

Views: 5467

Answers (1)

bigonroad
bigonroad

Reputation: 35

Consider using background-size: cover; to resize the image with the container.

Can you give us more of your css? Trying to edit your code, but there's not enough to work with at the moment... http://www.cssdesk.com/rccRc

Upvotes: 0

Related Questions