Flex-shrink example summary - more precision in explanation#42583
Open
OskarKaminski wants to merge 2 commits intomdn:mainfrom
Open
Flex-shrink example summary - more precision in explanation#42583OskarKaminski wants to merge 2 commits intomdn:mainfrom
OskarKaminski wants to merge 2 commits intomdn:mainfrom
Conversation
Contributor
|
Preview URLs Flaws (6)URL:
|
chrisdavidmills
requested changes
Jan 2, 2026
Contributor
chrisdavidmills
left a comment
There was a problem hiding this comment.
Thanks for the update, @OskarKaminski. I agree with your meaning, but I'd like to see the grammar improved a bit, plus I think it makes sense to explain all the sums rather than just a couple. See my suggestion below.
| {{EmbedLiveSample('Setting_flex_item_shrink_factor', 500, 100)}} | ||
|
|
||
| The flex items don't overflow their container because they are able to shrink: the `500px` of negative free space is distributed among the five items based on their `flex-shrink` values. The first three items have `flex-shrink: 1` set. D has `flex-shrink: 1.5` and E has `flex-shrink: 2` set. The final width of D and E is less than the others, with E smaller than D. | ||
| The flex items don't overflow their container because they are able to shrink: the `500px` of negative free space is distributed among the five items based on their `flex-shrink` values. Since a total of shrink values for the five items is `6.5`, width of items with `flex-shrink: 1` is reduced by `1/6.5 * 500px = 76.92px` and of item with `flex-shink: 2` by `2/6.5 * 500px = 153.85px`. |
Contributor
There was a problem hiding this comment.
Suggested change
| The flex items don't overflow their container because they are able to shrink: the `500px` of negative free space is distributed among the five items based on their `flex-shrink` values. Since a total of shrink values for the five items is `6.5`, width of items with `flex-shrink: 1` is reduced by `1/6.5 * 500px = 76.92px` and of item with `flex-shink: 2` by `2/6.5 * 500px = 153.85px`. | |
| The flex items don't overflow their container because they can shrink: the `500px` of negative free space is distributed among the five items based on their `flex-shrink` values. The total of all the shrink values for the five items is `1 + 1 + 1 + 1.5 + 2` = `6.5`. As a result, the width of items with `flex-shrink: 1` is reduced by `1/6.5 * 500px` = `76.92px`, the width of items with `flex-shrink: 1.5` is reduced by `1.5/6.5 * 500px` = `115.38px`, and the width of items with `flex-shink: 2` is reduced by `2/6.5 * 500px` = `153.85px`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Flex-shrink example summary - more precision in explanation
Motivation
After reading the section, it wasn't clear to me how it's calculated.
A reference for flex-grow explains it but it's not stated anywhere that flex-shrink uses the same mechanism.
Without clearly stating it, it may be counter-intuitive as a paragraph above mentions that those calculations are more complicated than for flex-grow.
Additional details
Related issues and pull requests