-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🐛 Restrict display:block/position:relative styles to implicit responsive layout #28020
🐛 Restrict display:block/position:relative styles to implicit responsive layout #28020
Conversation
Can you link me to a page that displays this?
Note that the second and third selectors are meant to be a pair, so they need to be updated together. |
Ok, I think this is actually due to -[width][height][sizes]:not(.i-amphtml-layout-responsive)
+[width][height][sizes]:not([layout=intrinsic]):not(.i-amphtml-layout-responsive) Or, to specify the implicit responsive only applies if there is no -[width][height][sizes]:not(.i-amphtml-layout-responsive)
+[width][height][sizes]:not([layout]) Unless, you feel this should also apply to |
I'm not sure what is preferable. In a WordPress context, we use |
I think we should update it to We can open a new PR if we want to add |
Applied in 3decb89. |
…ive layout (ampproject#28020) * Account for disable-inline-width attribute in ampshared.css * Restrict selector to only target implicit responsive
In #27083 the
disable-inline-width
attribute was introduced to allow “specifying thesizes
on elements without getting the sizing behavior of sizes in AMP (which adds a width based on which media query matches).” This addressed #21736.In the WordPress AMP plugin we wrestled a lot with AMP's
sizes
behavior (#17053), leading us ultimately to remove thesizes
attribute altogether to avoid it (ampproject/amp-wp#2036). This was not ideal because even though WordPress generates images withsizes
andsrcset
, for the sake of AMP we had to strip thesizes
out.When updating the validator spec in the plugin, I discovered the new
disable-inline-width
attribute and confirmed with @caroqliu that it would prevents AMP's defaultsizes
behavior.So we proceeded to eliminate the removal of the
sizes
attribute in favor of adding thedisable-inline-width
attribute when convertingimg
toamp-img
. It all seemed to work perfectly except for one particular case, where an image is added inline within a paragraph.In the non-AMP version and the AMP version when
sizes
is removed, the inline image is rendered like so:However, when
sizes
is retained withdisable-inline-width
added, the result is the image appearing on its own line:This is due to this CSS rule in
ampshared.css
:amphtml/css/ampshared.css
Lines 59 to 65 in 97099ce
It appears that the last selector in this rule (
[width][height][sizes]:not(.i-amphtml-layout-responsive)
) was not updated to account for the presence of thedisable-inline-width
attribute:The result is the element unexpectedly getting a
display:block
style rather than the expecteddisplay:inline-block
.Is there any need for elements with the
disable-inline-width
attribute to have these styles applied? If not, this PR excludes such elements from getting the styles unnecessarily.