Skip to content

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

Closed

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

Activity

  1. added
    needs triage
    on Sep 28, 2021
  2. changed the title [-]bug(COMPONENT): Picture elements on mat-cards have incorrect top-margin, when no heading is present[/-] [+]bug(mat-card): Picture elements on mat-cards have incorrect top-margin, when no heading is present[/+] on Sep 28, 2021
  3. added
    P3
    and removed
    needs triage
    on Sep 28, 2021
  4. self-assigned this
    on Oct 2, 2021
  5. added a commit that references this issue on Oct 2, 2021
    e9ca125
  6. crisbeto commented on Oct 2, 2021

    @crisbeto
    Member

    I've submitted #23678 to fix it. Note that you'll also have to move the mat-card-image attribute to the picture element itself.

  7. Trombach commented on Oct 4, 2021

    @Trombach
    Author

    @crisbeto Thanks for the quick fix! Much appreciated

  8. added a commit that references this issue on Oct 10, 2021
    626d26e
  9. added 2 commits that reference this issue on Jan 18, 2022
    267b03a
    761f9f2
  10. angular-automatic-lock-bot commented on Feb 18, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Feb 18, 2022
  12. added a commit that references this issue on Apr 3, 2022
    57751e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3area: material/card

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions