Closed ediamin closed 2 years ago
Thanks for investigating. This is a bug. Not sure though what the best way to fix this is.
!important
to amp-custom would fix this, but results in invalid AMPheights
attribute (as you suggested)heights
attributeI'm leaning towards 3, but there might be side-effects I'm not aware of.
heights
attribute contains padding-top value for multiple media queries to make it responsive. AFAIK, it is not possible to add media query in inline style.
Good point. Then this leaves only 2. as an option.
Related to https://github.com/ampproject/amp-toolbox-php/issues/511
Consider an example snippet like this
When we use an element with
heights
attribute the SSR or more specifically thecreateResponsiveSizer
method in ApplyLayout.js adds an inlinepadding-top
in the sizer element. But the SSR also generates amp-custom styles like this,For this output, the browser will always use the inline padding instead of the padding declared in amp-custom style. Hence, the generated markup is not responsive as expected.
In addition to that, according to the source code of amphtml, when we simply use the non-SSR element, it adds an inline padding-top using the
heights
attribute value. There is no affect of height/width ratio here. It only works if there is aheights
attribute.So, from my observation, we should remove the inline
padding-top
and only use the amp-custom style generated by theheights
attribute value to get a responsive sizer.