Wrong background-position with min/max/clamp on percentages
Categories
(Core :: Layout, defect)
Tracking
()
People
(Reporter: eyalgruss, Assigned: emilio)
References
(Regression, )
Details
(Keywords: regression)
Attachments
(1 file)
When using CSS min/max/clamp on percentage values in background-position, the result is wrong in Firefox (works in Chrome).
e.g. min(10%, 100%)
actually takes the larger value.
body {
background-image: url('https://img.freepik.com/free-vector/english-alphabets-many-colors_1308-4763.jpg');
background-size: 200%;
background-position-x: min(10%, 100%);
}
Comment 2•1 year ago
|
||
Set release status flags based on info from the regressing bug 1709018
:emilio, since you are the author of the regressor, bug 1709018, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
Assignee | ||
Comment 3•1 year ago
|
||
This is actually the correct behavior, afaict. https://drafts.csswg.org/css-backgrounds-3/#background-position says:
A percentage for the horizontal offset is relative to (width of background positioning area - width of background image).
Since the background-image (due to the background-size) is larger than the background positioning area, the percentage basis is negative. This is precisely the bug bug 1709018 was fixing.
In fact, Chrome and Safari behave like us if you use the background-position shorthand, but not if you use the background-position-x
longhand for some reason.
Assignee | ||
Comment 4•1 year ago
|
||
Will add a test, but the bug itself is invalid.
Assignee | ||
Comment 5•1 year ago
|
||
See https://bugzilla.mozilla.org/show_bug.cgi?id=1874606#c3 (and the
test is self-explanatory, it's just a copy of
background-position-negative-percentage-comparison.html but with the
longhand expanded).
Updated•1 year ago
|
Reporter | ||
Comment 6•1 year ago
|
||
so it seems that instead of clamp(0%, var(--dx), 100%)
one should write clamp(100%, var(--dx), 0%)
Assignee | ||
Comment 7•1 year ago
|
||
If the image is larger than the positioning area, sure.
Updated•1 year ago
|
Comment 10•1 year ago
|
||
bugherder |
Comment 11•1 year ago
|
||
bugherder |
Description
•