align-self in CSS Flexbox – How to Layout Flex Item
align-self specifies how browsers should position selected flexible items along the flexbox’s cross-axis.
The align-self
property accepts the following values:
stretch
flex-start
center
flex-end
baseline
Let’s discuss the five values.
What Is align-self: stretch
in CSS Flexbox?
stretch
stretches the selected flexible items to fill the flexbox’s cross-axis.
Here’s an example:
We used the stretch
value to stretch flex-item2
to fill the <section>
’s cross-axis.
What Is align-self: flex-start
in CSS Flexbox?
flex-start
aligns the selected flexible items with the cross-start edge of the flexbox’s cross-axis.
Here’s an example:
The snippet above used the flex-start
value to align flex-item2
to the cross-start edge of the <section>
’s cross-axis.
What Is align-self: center
in CSS Flexbox?
center
aligns the selected flexible items to the center of the flexbox’s cross-axis.
Here’s an example:
The snippet above used the center
value to align flex-item2
to the center of the <section>
’s cross-axis.
Build your website with Namecheap
What Is align-self: flex-end
in CSS Flexbox?
flex-end
aligns the selected flexible items with the cross-end edge of the flexbox’s cross-axis.
Here’s an example:
The snippet above used the flex-end
value to align flex-item2
to the cross-end edge of the <section>
’s cross-axis.
Learn Flexbox with Images
What Is align-self: baseline
in CSS Flexbox?
baseline
aligns the selected flexible items with the baseline of the flexbox’s cross-axis.
Here’s an example:
We used the baseline
value to align flex-item2
to the <section>
’s baseline.