-
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
I2I: Use aspect ratio CSS to implement responsive layout #30291
Comments
The |
Aspect Ratio CSS has landed in Chrome 88. |
Runtime launch is at 100% |
Findings from the 1% launch. In a wide majority of cases the Possible ways forward:
|
My vote is 2. I actually think this is backwards compatible with |
The issue is that while we haven't explicitly communicated anywhere how |
Ohhh, I mistakenly thought that forcing |
I'll try |
Were there any more updates here? Based on the difficulties above, my instinct is that we should do (4) now.
|
Based on a discussion with @dvoytenko, a potential path forward is to:
Going to start by implementing (1) in #36318 |
That sounds good to me. |
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. |
Summary
The new
aspect-ratio
CSS layout from CSS Sizing 4 is being actively worked on in Chrome and Firefox.This CSS should eventually supersede
layout=responsive
. In the meantime, the proposal is to reimplementlayout=responsive
viaaspect-ratio
CSS where it's available.See demos here.
Implementation brief
On the surface, the implementation is trivial:
The situation is a lot more complex with AMP optimizer because there's no way to confirm the
aspect-ratio
CSS support on that level. This is still TBD, but one approach we can take:In this approach, the optimizer will add both: new and legacy markup and we will control which one is used on the client side using the
@supports()
CSS.Motivation
First, the
aspect-ratio
CSS layout is designed to be more universal. Thelayout=responsive
is implemented via a fake element with thepadding-top: {height/width * 100}%
hack. This hack only works for bound-width case, such as normal block flow or flex-row layout. It doesn't work correctly for bound-height (e.g. flex-column) layouts and bound-width-and-height (position:absolute
) layouts.aspect-ratio
CSS will eventually support all three use cases.Second, the
aspect-ratio
CSS layout will work better with out CSS constraints such asmin-width
andmax-height
.Third, it's expected to be faster, since no fake elements are injected. In fact, eventually,
aspect-ratio
CSS will require no JS involvement at all. This would be a big benefit to CLS metric.Fourth, in the Bento world, the fewer fake elements are injected the better. This is because any fake element will be visible to the user script and can confuse its behavior.
Launch
The following steps are necessary for launch:
Implement client-side support for "intrinsic" layout./cc @ampproject/wg-approvers
The text was updated successfully, but these errors were encountered: