Skip to content

Conversation

@OskarKaminski
Copy link

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

@OskarKaminski OskarKaminski requested a review from a team as a code owner December 31, 2025 11:17
@OskarKaminski OskarKaminski requested review from chrisdavidmills and removed request for a team December 31, 2025 11:17
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed labels Dec 31, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Preview URLs

Flaws (6)

URL: /en-US/docs/Web/CSS/Reference/Properties/flex-shrink
Title: flex-shrink
Flaw count: 6

  • broken_links:
    • Link /en-US/docs/Web/CSS/number#interpolation is a redirect
    • Link /en-US/docs/Web/CSS/number is a redirect
  • macros:
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Value_processing which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Inheritance which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Value_processing which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_animated_properties which is a redirect

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a 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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants