Closed Bug 1910290 Opened 1 year ago Closed 1 year ago

Flex item containing an image is too large on the cross axis with flex-direction: column & max-height

Categories

(Core :: Layout: Flexbox, defect)

Firefox 129
defect

Tracking

()

RESOLVED DUPLICATE of bug 1926015

People

(Reporter: wall, Unassigned)

References

Details

Attachments

(3 files, 2 obsolete files)

Attached image firefox.png

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0

Steps to reproduce:

Open the following example:

<style>
  .outer {
    border: 2px solid red;
    padding: 2px;
    width: 800px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .inner {
    max-height: 100%;
    background: green;
  }

  img {
    max-height: 100%;
  }
</style>

<div class="outer">
  <div class="inner">
    <img src="https://picsum.photos/id/237/600/600" />
  </div>
</div>

Actual results:

In Firefox, the .inner div grows to 600px on the cross axis (width).

Firefox does not show this issue in the following cases:

  • changing max-height to height
  • changing the flex direction to row (flip width and height on the outer div & change max-height to max-width)

Expected results:

Chrome and Safari limit the inner div to the actual maximum width of the image (300px in this case).

Attached image chrome.png

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Flexbox' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Flexbox
Product: Firefox → Core
Assignee: nobody → aethanyc
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

I didn't mean to take this. I wrongly attached my patches to this bug.

However, I'm currently working on bug 1909761, and I think it might fix the testcase here.

Severity: -- → S3
Status: ASSIGNED → NEW
Depends on: 1909761

Tested in Firefox 132.0a1 (2024-09-03). Testcase 1 in comment 7 now looks fine.

Status: NEW → RESOLVED
Closed: 1 year ago
No longer depends on: 1909761
Duplicate of bug: 1909761
Resolution: --- → DUPLICATE

The testcase was accidentally fixed in bug 1909761. Later, I proposed a new approach in bug 1918576. Unfortunately, the solution causes a performance regression reported in bug 1920084. Due to time constraint, I decided to revert the solution and reopen this bug. We can continue to develop a solution here.

Assignee: aethanyc → nobody
Status: RESOLVED → REOPENED
No longer duplicate of bug: 1909761
Resolution: DUPLICATE → ---

From some brief testing, I think the attached testcase is fixed (matches Chrome's rendering) in latest Nightly and can perhaps be closed as a dupe of bug 1926015 -- TYLin, could you confirm?

Flags: needinfo?(aethanyc)

Yes, this bug is fixed by 1926015. I test it on Nightly 134.0a1 (2024-11-22).

The testcase has been captures as a wpt in https://wpt.fyi/results/css/css-sizing/intrinsic-percent-replaced-017.html.

Status: REOPENED → RESOLVED
Closed: 1 year ago1 year ago
Duplicate of bug: 1926015
Flags: needinfo?(aethanyc)
Resolution: --- → DUPLICATE
See Also: 1926015, 1931491
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: