Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amp-img with layout responsive doesn't work in flexbox #21790

Open
cathyxz opened this issue Apr 9, 2019 · 3 comments
Open

amp-img with layout responsive doesn't work in flexbox #21790

cathyxz opened this issue Apr 9, 2019 · 3 comments

Comments

@cathyxz
Copy link
Contributor

cathyxz commented Apr 9, 2019

Repros in Chrome here: https://codepen.io/cathyxz/pen/wZgQqY?editors=1100

Basically today @kristoferbaxter discovered that when you have:

#container {
  display: flex;
  height: 100vh;
  width: 100vw;
  align-items: center;
  justify-content: center;
}

and

  <div id="container">
    <amp-img src="http://placekitten.com/300/300" 
             width="300" 
             height="300" 
             layout="responsive">
    </amp-img>
  </div>

in AMP, the <amp-img> does not display. =(

It turns out that the dimensions of both the <amp-img> and the sizer are 0x0, and therefore the <img> tag is not rendered because the layoutCallback is not called.

This does work with layout="intrinsic" though, and layout="responsive" will work correctly as intended if we set the flex-basis property on the <amp-img>. But not out of the box. Since this is a commonly used pattern for centering images, it seems like we should document this behaviour and workarounds at least.

@meistudioli
Copy link
Contributor

Hi, @cathyxz

I just fire an issue about amp-img doen't init. Just wondering is it same with your case ?

issue: #25789

Paul

@cathyxz cathyxz removed their assignment Jun 24, 2020
@stale
Copy link

stale bot commented Sep 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Sep 28, 2022
@vinoddhanda
Copy link

You can use "Flex:1" its work for me
#container {
display: flex;
height: 100vh;
width: 100vw;
align-items: center;
justify-content: center;
flex:1;
}

@stale stale bot removed the Stale Inactive for one year or more label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants