I noticed in the flexbox specification that flex-basis
can be set to content
.
I'm trying to use that in the html. But it's not working in chrome.
Can someone show me an example for flex-basis: content
?
Thank you.
The flex-basis property is a sub-property of the Flexible Box Layout module. It specifies the initial size of the flex item, before any available space is distributed according to the flex factors. When omitted from the flex shorthand, its specified value is the length zero.
flex: 0 1 200px; Here flex-basis is acting like a maximum width. An element that has a flex shrink value of 0, a flex grow value of 0, but has a flex basis pixel value, will only ever be that pixel value size. It won't shrink and it won't grow. This would be the same as setting a pixel value to the width property.
A flex container expands items to fill available free space or shrinks them to prevent overflow. Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based).
Note that the content
value is not yet supported by most major browsers.
Here's a screenshot from MDN:
For an explanation about what content
does, MDN is also helpful:
content
Indicates automatic sizing, based on the flex item’s content.
Note: Note that this value was not present in the initial release of Flexible Box Layout, and thus some older implementations will not support it. The equivalent effect can be had by using
auto
together with a main size (width or height) ofauto
.Note: Brief history
- Originally,
flex-basis: auto
meant "look at my width or height property".- Then,
flex-basis: auto
was changed to mean automatic-sizing, and "main-size" was introduced as the "look at my width or height property" keyword.- Then, that change was reverted, so
auto
once again means "look at my width or height property"; and a newcontent
keyword is being introduced to trigger automatic sizing.source: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis#Values
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With