max-width:100% is not respected within auto-width inline blocks

RESOLVED FIXED in Firefox 46

Status

()

Core
Layout: Block and Inline
P4
normal
RESOLVED FIXED
4 years ago
a year ago

People

(Reporter: Nicolas Gallagher, Unassigned)

Tracking

({testcase})

25 Branch
mozilla47
x86
All
testcase
Points:
---

Firefox Tracking Flags

(firefox45 affected, firefox46 fixed, firefox47 fixed)

Details

(Whiteboard: [bugday-20131106])

Attachments

(2 attachments)

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Steps to reproduce:

Image with 'max-width:100%' within an inline-block.

Test case:

http://codepen.io/anon/pen/BzLmv

Compare to Google Chrome.


Actual results:

Image does not respect max-width of ancestral context. It breaks out of the containing block element (gray box in test case).


Expected results:

It should not exceed 100% of the width of the ancestral context. It should be bound by the containing block element (gray box in test case).

Comment 1

4 years ago
Confirmed with 2013-11-06-03-02-00-mozilla-central-firefox-28.0a1.en-US.linux-x86_64: 100% translates to the image's real width 300px.
Component: Untriaged → Layout: Block and Inline
OS: Mac OS X → All
Product: Firefox → Core
Whiteboard: [bugday-20131106]
So the inline block has auto width, which means it shrink-wraps its kids.  But the width of the kids depends on the width of the inline-block because of the max-width style (which is a percentage of the width of the inline block, not of the gray 200px wide block, in this testcase).  The only way in which the 200px width enters the picture is that it's the available width for the shrink-to-fit algorithm.

So the real question here is what the "preferred minimum width" is in this case.  That's basically what the discussion in bug 823483 is about.

Note that the CSS specification does not actually define the rendering here, unfortunately, which is why different browsers handle it differently...
Depends on: 823483
Created attachment 828326 [details]
Testcase

Updated

4 years ago
Keywords: testcase
Priority: -- → P4
Duplicate of this bug: 1138406
Summary: max-width:100% is not respected within inline blocks → max-width:100% is not respected within auto-width inline blocks

Comment 5

2 years ago
Created attachment 8582024 [details]
workaround.htm

For me (Win7, FF 36) wrapping the image within an element styled like this
{
 display: table;
 table-layout: fixed;
 width: 100%;
}
fixes the issue.

See also bug 504622, bug 823483.
fixed by bug 823483.
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Resolution: --- → FIXED
status-firefox45: --- → affected
status-firefox46: --- → fixed
status-firefox47: --- → fixed
Target Milestone: --- → mozilla47
You need to log in before you can comment on or make changes to this bug.