Skip to content

Flexbox - Growing and Shrinking lesson: update flex shorthand section for clarity with note on default values #29603

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set

In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`.

By default, the `flex` shorthand property is set to: `flex-grow: 0`, `flex-shrink: 1`, `flex-basis: auto`. This means the item won't grow, can shrink, and its size is based on content.

![flex shorthand](https://cdn.statically.io/gh/TheOdinProject/curriculum/0cc6b26bb0c4b94524369d327c97a8fb11e83b6b/foundations/html_css/flexbox/imgs/10.png)

In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`.
In the above screenshot, `flex: 1` is shorthand for: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`.

Note: The default `flex-basis: auto` is overwritten to `flex-basis: 0`

Very often you see the flex shorthand defined with only *one* value. In that case, that value is applied to `flex-grow`. So when we put `flex: 1` on our divs, we were actually specifying a shorthand of `flex: 1 1 0`.

Expand Down