Flex item containing an image is too large on the cross axis with flex-direction: column & max-height
Categories
(Core :: Layout: Flexbox, defect)
Tracking
()
People
(Reporter: wall, Unassigned)
References
Details
Attachments
(3 files, 2 obsolete files)
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-heighttoheight - changing the flex direction to row (flip
widthandheighton the outer div & changemax-heighttomax-width)
Expected results:
Chrome and Safari limit the inner div to the actual maximum width of the image (300px in this case).
Comment 2•1 year ago
|
||
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.
| Comment hidden (obsolete) |
Updated•1 year ago
|
| Comment hidden (obsolete) |
| Comment hidden (obsolete) |
| Comment hidden (obsolete) |
Comment 7•1 year ago
|
||
Comment 8•1 year ago
|
||
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.
Comment 9•1 year ago
|
||
Tested in Firefox 132.0a1 (2024-09-03). Testcase 1 in comment 7 now looks fine.
Comment 10•1 year ago
|
||
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.
Comment 11•1 year ago
|
||
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?
Comment 12•1 year ago
|
||
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.
Description
•