amphtml: amp-img with layout intrinsic stretches to fill parent if display: block

It’s possible and sometimes common to have CSS overrides to set amp-img to display: block. When this happens, <amp-img> with layout intrinsic ends up stretching to fill the entire parent container instead of maintaining its correct aspect ratio.

Here’s a minimal repro: https://codepen.io/cathyxz/pen/PLJmyQ. When display: block !important is applied to <amp-img>, the image stretches to fill the container width.

~Related: https://codepen.io/cathyxz/pen/JzmLYE. When display: inline is applied to <amp-img> with layout=intrinsic, the image fails to render.~ behaving as intended.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (16 by maintainers)

Commits related to this issue

Most upvoted comments