Skip to content
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

Maintenance: CSS flex guide: updates to guide 5 #34237

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

estelle
Copy link
Member

@estelle estelle commented Jun 18, 2024

Flexbox is well-supported, and the content value is fully supported. This update freshens up the guide and removes a lot of words to tighten it up, then adds clarification text, so it's about the same size :(.

updating guide as part of CSS baseline / interop openwebdocs/project#189 - subcomponent openwebdocs/project#202

@estelle estelle requested a review from a team as a code owner June 18, 2024 02:55
@estelle estelle requested review from dipikabh and removed request for a team June 18, 2024 02:55
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/m [PR only] 51-500 LoC changed labels Jun 18, 2024
Copy link
Contributor

github-actions bot commented Jun 18, 2024

Preview URLs

(comment last updated: 2024-06-29 02:05:18)

@estelle estelle changed the title Maintenance: CSS flex guide: updates to guide 3 Maintenance: CSS flex guide: updates to guide 5 Jun 18, 2024
@estelle estelle mentioned this pull request Jun 18, 2024
29 tasks
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Jun 28, 2024
@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Jun 28, 2024
…_of_flex_items_along_the_main_axis/index.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@dipikabh dipikabh 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 improving this content, @estelle. I've added my editorial review.

Comment on lines 156 to 158
2. Is `flex-basis` set to `auto`? If so, the size is based on the item size.
3. Is `flex-basis` a length or percentage, but not zero? If so this is the size of the item (floored at `min-content`).
4. Is `flex-basis` set to `0`? If so, the item's size is not taken into consideration for the space-sharing calculation.
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
2. Is `flex-basis` set to `auto`? If so, the size is based on the item size.
3. Is `flex-basis` a length or percentage, but not zero? If so this is the size of the item (floored at `min-content`).
4. Is `flex-basis` set to `0`? If so, the item's size is not taken into consideration for the space-sharing calculation.
- Is `flex-basis` set to `auto`? If so, the size will be based on the item's content size.
- Is `flex-basis` a length or a percentage, but not zero? If so, this will be the size of the item (floored at `min-content`).
- Is `flex-basis` set to `0`? If so, the item's size will not be taken into consideration for the space-sharing calculation.

4. Is `flex-basis` set to `0`? if so then the item size is not taken into consideration for the space-sharing calculation.
2. Is `flex-basis` set to `auto`? If so, the size is based on the item size.
3. Is `flex-basis` a length or percentage, but not zero? If so this is the size of the item (floored at `min-content`).
4. Is `flex-basis` set to `0`? If so, the item's size is not taken into consideration for the space-sharing calculation.

### Do we have available space?

Items can't grow with no positive free space, and they won't shrink unless there is negative free space.
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
Items can't grow with no positive free space, and they won't shrink unless there is negative free space.
Items can't grow without positive free space, and they won't shrink unless there is negative free space.

Comment on lines 164 to 165
1. If we add up the widths of all the items (or heights if working in a column), is that total **less** than the total width (or height) of the container? If so, then you have positive free space and `flex-grow` comes into play.
2. If we add up the widths of all the items (or heights if working in a column), is that total **more** than the total width (or height) of the container? If so, you have negative free space and `flex-shrink` comes into play.
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
1. If we add up the widths of all the items (or heights if working in a column), is that total **less** than the total width (or height) of the container? If so, then you have positive free space and `flex-grow` comes into play.
2. If we add up the widths of all the items (or heights if working in a column), is that total **more** than the total width (or height) of the container? If so, you have negative free space and `flex-shrink` comes into play.
- If we add up the widths of all the items (or heights if working in a column), is that total **less** than the total width (or height) of the container? If so, there will be positive free space, and `flex-grow` will come into play.
- If we add up the widths of all the items (or heights if working in a column), is that total **more** than the total width (or height) of the container? If so, there will be negative free space, and `flex-shrink` will come into play.

1. If we took all of the items and added up their widths (or heights if working in a column), is that total **less** than the total width (or height) of the container? If so, then you have positive free space and `flex-grow` comes into play.
2. If we took all of the items and added up their widths (or heights if working in a column), is that total **more** than the total width (or height) of the container? If so, you have negative free space and `flex-shrink` comes into play.
1. If we add up the widths of all the items (or heights if working in a column), is that total **less** than the total width (or height) of the container? If so, then you have positive free space and `flex-grow` comes into play.
2. If we add up the widths of all the items (or heights if working in a column), is that total **more** than the total width (or height) of the container? If so, you have negative free space and `flex-shrink` comes into play.

### Other ways to distribute space

If you do not want space added to the items, remember that you can deal with free space between or around items using the alignment properties described in the guide to aligning items in a flex container. The {{CSSxRef("justify-content")}} property will enable the distribution of free space between or around items. You can also use auto margins on flex items to absorb space and create gaps between items.
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
If you do not want space added to the items, remember that you can deal with free space between or around items using the alignment properties described in the guide to aligning items in a flex container. The {{CSSxRef("justify-content")}} property will enable the distribution of free space between or around items. You can also use auto margins on flex items to absorb space and create gaps between items.
If you do not want space added to the items, remember that you can manage free space between or around items using the alignment properties described in the guide for aligning items in a flex container. The {{CSSxRef("justify-content")}} property will enable the distribution of free space between or around items. You can also use auto margins on flex items to absorb space and create gaps between items.


### Other ways to distribute space

If you do not want space added to the items, remember that you can deal with free space between or around items using the alignment properties described in the guide to aligning items in a flex container. The {{CSSxRef("justify-content")}} property will enable the distribution of free space between or around items. You can also use auto margins on flex items to absorb space and create gaps between items.

With all the flex tools at your disposal you will find that most tasks can be achieved, although it might take a little bit of experimentation at first.
With all these flex properties available to you, you will find that most tasks can be achieved, although it might take a little bit of experimentation at first.
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
With all these flex properties available to you, you will find that most tasks can be achieved, although it might take a little bit of experimentation at first.
With all these flex properties available to you, you will find that most layout tasks are possible, although it might take a little bit of experimentation at first.


Working from a `flex-basis` of `0` this means that the available space is distributed as follows. We need to add up the flex grow factors, then divide the total amount of positive free space in the flex container by that number, which in this case is 4. We then share out the space according to the individual values — the first item gets one part, the second one part, the third two parts. This means that the third item is twice the size of the first and second items.
In the example below, we use `1` as the `flex-grow` factor for the first two items and double it to `2` for the third item. With `flex-basis: 0` set on all the items, the available space is distributed as follows:
1. The `flex-grow` factor values of all the sibling flex items are added together (the total is 4 in this case).
Copy link
Contributor

Choose a reason for hiding this comment

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

[mdn-linter] reported by reviewdog 🐶

Suggested change
1. The `flex-grow` factor values of all the sibling flex items are added together (the total is 4 in this case).
1. The `flex-grow` factor values of all the sibling flex items are added together (the total is 4 in this case).

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/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants