-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Flex-shrink example summary - more precision in explanation #42583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Preview URLs Flaws (6)URL:
|
chrisdavidmills
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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`. |
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