0

I'm trying to put an image inside a mat-card so that it takes the full height of the card -

<mat-card class="mat-elevation-z4">
    <img src="/assets/images/the-godfather.jpg" width="300">
</mat-card>

I removed the padding of the card -

mat-card {
    width: 600px;
    border-radius: 0;
    padding: 0;
}

But there's always a little space below the image when it renders, as shown below -

enter image description here

The original image dimension is 700x1000. So it's no like it is falling short in height to keep the aspect ratio. I couldn't find any padding/margin in browser Dev tool that might cause that extra space.

Can anyone give a clue?

atiyar
  • 7,762
  • 6
  • 34
  • 75

1 Answers1

-1
<mat-card class="mat-elevation-z4">
  <img src="/assets/images/the-godfather.jpg">
</mat-card>

CSS

mat-card {
  width: 600px;
  border-radius: 0;
  padding: 0;

  > img {
    height: 100%;
  }
}
Marlon Berdefy
  • 321
  • 2
  • 11
  • 5
    While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – β.εηοιτ.βε Jun 12 '20 at 19:25