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

[css-sizing] Image aspect ratio revert to original width and height attribute #5836

Closed
nextend opened this issue Jan 5, 2021 · 2 comments
Closed

Comments

@nextend
Copy link

nextend commented Jan 5, 2021

Width and height attributes for images define the aspect ratio of that image since: whatwg/html#4952

There should be a way in CSS to revert back to this original behavior if some other components redefined the width/height of that image in CSS.

Here is an example: https://jsfiddle.net/g74a0me2/1/

The following redefines the width and height of the image, so the aspect ratio won't work as the attributes are overridden.

img {
  width: 100%;
  height: 100wh;
}

Then we want to restore the original aspect ratio functionality for a subset of elements, but there is no way. For example with any of the following:

.my-image {
  width: auto;
  height: auto;
}

.my-image {
  width: initial;
  height: initial;
}

.my-image {
  width: revert;
  height: revert;
}

.my-image {
  width: attr(width px);
  height: attr(height px);
}

Related Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1161102#c9

@fantasai
Copy link
Collaborator

fantasai commented Jan 8, 2021

All of the methods you've described should restore the aspect ratio. None of them except the last one will restore the image to its attribute-specified size (but the last one, in theory, should have that effect).

For Cascade 5, we might want to make sure the HTML preshint level of the cascade is in a separate layer so that the single-layer revert being proposed in #5793 can unwind down but leave preshints untouched.

@tabatkins
Copy link
Member

tabatkins commented Mar 11, 2021

Right; since the aspect-ratio preshint isn't overridden in any of the cases presented here, and the remaining issue (explicitly reverting back to the width and height preshints) is covered by #5856, I'll close this issue as invalid.

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

3 participants