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

[css-flexbox-1][css-grid-1] Note to explain flex values < 1 #2617

Closed
fantasai opened this issue Apr 26, 2018 · 3 comments
Closed

[css-flexbox-1][css-grid-1] Note to explain flex values < 1 #2617

fantasai opened this issue Apr 26, 2018 · 3 comments
Labels
Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-flexbox-1 Current Work css-grid-1 Tracked in DoC

Comments

@fantasai
Copy link
Collaborator

Add a note explaining flex values < 1. See https://logs.csswg.org/irc.w3.org/css/2018-04-26/#e1010206

@jonjohnjohnson
Copy link

I remember discovering this a few years ago when differences appeared alongside flex-wrap: wrap

https://jsfiddle.net/t2ewf2ac/

@fantasai fantasai changed the title [css-flexbox-1][css-grid-1] [css-flexbox-1][css-grid-1] Note to explain flex values < 1 Apr 26, 2018
@simevidas
Copy link
Contributor

simevidas commented May 6, 2018

Assuming that the flex total is less than 1, then something like flex: 0.15 seems to be equivalent to this:

{
  min-width: fit-content;
  width: 15%;
}

Demo: https://codepen.io/simevidas/pen/erGXRZ?editors=1100

Is that correct? If yes, is there a reason to use one over the other (are there any notable side effects)?

fergald pushed a commit to fergald/csswg-drafts that referenced this issue May 7, 2018
@tabatkins
Copy link
Member

If that's the only item in the flexbox, then yeah, it's roughly equivalent. But in general it's not - the flex: 0.15 element only takes 15% of the free space, which might be reduced by other flex items, while a width: 15% element takes 15% of the available space inside the flexbox, regardless of what other flex items there might be. The flex one also reduces its size when there are more flexible elements such that the sum of the flexes is >1; the width one doesn't care.

@fantasai fantasai added the Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. label Aug 24, 2018
@fantasai fantasai added this to the css-grid-1 CR 2017-12-14+ milestone Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-flexbox-1 Current Work css-grid-1 Tracked in DoC
Projects
None yet
Development

No branches or pull requests

4 participants