Advertisement

Google Ad Slot: content-top

Bootstrap 5 Flex Items

~1 min read · Bootstrap
On this page

Flex items in CSS are the child elements of a flex container.


Order:

Specifies the order of the flex item within the container.


Syntax:

order-{size?}-{value}
  • order: Indicates flex order.
  • size (optional): Responsive breakpoint (e.g., sm : ≥576pxmd : ≥ 768pxlg : ≥992pxxl : ≥1200pxxxl : ≥1400px).
  • value (optional): Responsive breakpoint (e.g., 012345):


Example:

  • .order-1
  • .order-sm-1
  • .order-md-1
  • .order-lg-1
  • .order-xl-1
  • .order-xxl-1
1
2
3
Example
1
2
3
Try it yourself

Flex Grow & Flex Shrink:


Syntax:

flex-{size?}-{type}-{value}
  • flex: Indicates flex.
  • size (optional): Responsive breakpoint (e.g., sm : ≥576pxmd : ≥ 768pxlg : ≥992pxxl : ≥1200pxxxl : ≥1400px).
  • type : grow | shrink:
  • value : size (e.g., 01):


Example:

  • .flex-{grow | shrink}-0
  • .flex-sm-{grow | shrink}-1
  • .flex-md-{grow | shrink}-1
  • .flex-lg-{grow | shrink}-1
  • .flex-xl-{grow | shrink}-1
  • .flex-xxl-{grow | shrink}-1
Flex Grow
1
2
2
3

Flex Shrink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Flex grow Example
1
2
2
3
Try it yourself
Flex shrink Example
1
2
3
4
5
6
7
8
9
10
11
12
13
Try it yourself

Align Self:

Align an individual flex item vertically.


Syntax:

align-self-{size?}-{type}
  • align-self: Indicates flex align self.
  • size (optional): Responsive breakpoint (e.g., sm : ≥576pxmd : ≥ 768pxlg : ≥992pxxl : ≥1200pxxxl : ≥1400px).
  • type : Defines the direction of the margin (e.g., startendcenterbaseline,stretch).


Example:

  • .align-self-start
  • .align-self-sm-start
  • .align-self-md-start
  • .align-self-lg-start
  • .align-self-xl-start
  • .align-self-xxl-start
1
2
3
4
5
Example
1
2
3
4
5
Try it yourself