This is the base size of the item before growth or shrink is applied.
- By default it is auto, which takes the natural size of the content or the defined width/height.
- It can be a value in px, %, auto, rem, em, etc.
Example
In this example, we can see how each item takes its width according to the value assigned through the flex-basis property.
12345
<div class="container">
<span class="child-1">1</span>
<span class="child-2">2</span>
<span class="child-3">3</span>
</div>
123456789101112131415161718192021
.container {
border: 1px solid #2b7de0;
display: flex;
gap: 1rem;
padding: 0.5rem;
}
.child-1 {
flex-basis: auto;
padding: 1rem;
}
.child-2 {
flex-basis: 90px;
padding: 1rem;
}
.child-3 {
flex-basis: 12rem;
padding: 1rem;
}