Skip to content

bug(mat-card): Picture elements on mat-cards have incorrect top-margin, when no heading is present #23649

Closed
@Trombach

Description

@Trombach

Reproduction

Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/components-issue-5lp7n2?file=src/app/example-component.html

Steps to reproduce:

  1. Create a <mat-card> element with no title, or subtitle
  2. Add a <picture> element with at least one <source> element
<mat-card>
  <picture>
    <source
      srcset="https://material.angular.io/assets/img/examples/shiba2.jpg"
    />
    <img mat-card-image />
  </picture>
</mat-card>

Expected Behavior

What behavior were you expecting to see?

The top of the image should be flush with the top edge of the card, just like when using an <img/> tag

Actual Behavior

What behavior did you actually see?

There was a gap between the top edge of the card and the image. This is due to how the css class that overwrites the padding of the card is applied here.

Environment

  • Angular:
  • CDK/Material: 12.2.7
  • Browser(s): Chrome 94, Safari 15
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/card

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions