-
Notifications
You must be signed in to change notification settings - Fork 22.4k
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
base: main
Are you sure you want to change the base?
Conversation
Preview URLs (comment last updated: 2024-06-29 02:05:18) |
This pull request has merge conflicts that must be resolved before it can be merged. |
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
…_of_flex_items_along_the_main_axis/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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 improving this content, @estelle. I've added my editorial review.
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
...eb/css/css_flexible_box_layout/controlling_ratios_of_flex_items_along_the_main_axis/index.md
Outdated
Show resolved
Hide resolved
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. |
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.
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. |
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.
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. |
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. |
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.
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. |
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.
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. |
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.
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. |
Co-authored-by: Dipika Bhattacharya <[email protected]>
|
||
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). |
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.
[mdn-linter] reported by reviewdog 🐶
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). |
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