w3c / w3c/csswg-drafts

[css-grid][css-flexbox][quirks] Avoid percentage height quirk in new layout models

Open
#5,545 19 comments 0 reactions 1 assignee View on GitHub

@zcorpan is already working on this.

Since Nov 7, 2024.

Closed Accepted by CSSWG Resolution css-flexbox-1 css-grid-1 Needs Edits
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

Quirks mode has this percentage quirk which skips ancestors with height: auto when resolving height: <percentage>. Basically, it's resolved against the nearest ancestor in the containing block chain that doesn't have height: auto.

There are some exceptions: grid and flex containers are not skipped.

But we still have an interoperability problem: Firefox doesn't skip grid and flex items, while Chromium does. Testcase

<div style="display: flex; height: 100px; width: max-content; border: 5px solid blue">
  <div style="width: 100px; align-self: center; border: 3px solid lime">
    <div style="height: 100%; background: red"></div>
  </div>
</div>
<div style="display: grid; grid-template-rows: 100px; width: max-content; border: 5px solid blue">
  <div style="width: 100px; align-self: center; border: 3px solid lime">
    <div style="height: 100%; background: red"></div>
  </div>
</div>

screenshot

I think Firefox is right and the quirk should be avoided for elements that participate in new layout models (like grid-level and flex-level boxes).

It's not just that quirks shouldn't infect new features. There is also the thing that stretched grid/flex items are considered to have a definite height, even if they have height: auto. So skipping them in that case doesn't even make sense. And skipping them depending on whether the height will end up being definite or not would just make it harder for implementations.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.