Flexbox gives you precise alignment and stacking control for all the contents inside an element, solving many layout problems that designers struggle with.

This video features an old UI. Updated version coming soon!
This video features an old UI. Updated version coming soon!

Flexbox, also known as flex or flexible box layout, allows you to control the alignment of elements in a box in any way you’d like — solving complex layout problems that designers have been struggling with for years.

In this lesson:

  1. Flex parents
  2. Flex children
  3. Flex parent settings
  4. Flex child settings

Flex parents

The flex parent is the parent element. You can create a flex container out of any element that already has elements inside of it. To create a flex parent out of an element, select the element and set the display setting to flex.

Unlike other display settings, enabling flex on a parent element will affect the layout of the direct children elements inside of it. When you enable the flex display setting for a parent element, the children of that parent element align to the left and stack horizontally by default.

Flexbox in Webflow

Flex containers will not affect or change the layout of the children within their direct, child elements.

Flex children  

Once you’ve created a flex container out of a parent element, the direct children of that element become flex children. To override the layout settings for a flex child, select the element and adjust the layout settings.

Flex parent settings

Once you change the layout setting of a parent element to flex, you’ll have a number of layout options for both the flex parent child elements they contain.

Set the layout direction

The direction of a flex parent is set to horizontal by default. You can switch the direction to vertical in the flex layout settings.

Reverse the layout direction

You can reverse the alignment of your flex parent layout in the direction settings. Reversing the layout of your flex parent is especially useful for RTL sites and when it’s necessary to reverse layouts on smaller breakpoints.

Update the alignment of flex children

To change the alignment of flex children within a flex parent, select the flex parent and select your desired alignment under the layout direction settings.

Horizontal alignment options

To align child elements horizontally, select one of the following alignment options:

  • Start - items are left aligned
  • Center - items are centered
  • End - items are right aligned
  • Space between - items are evenly distributed from edge to edge
  • Space around - items are evenly distributed along between elements and edges
Flexbox in Webflow

Vertical alignment options

To align flex children vertically, select one of the following alignment options:

  • Start - items are aligned to the top
  • Center - items are centered vertically
  • End - items are aligned to the bottom
  • Stretch - items are stretched across the height of the flex container
  • Baseline - items are aligned to their baselines (the invisible line that text sits on)
Flexbox in Webflow

Wrap Children

By default, flex children will always try to fit on a single line. You can change that by wrapping the children in the layout settings.

There are different options for aligning multiple rows of content horizontally:

  • Start - rows are aligned to the top of the flex parent
  • Center - rows are vertically centered inside the flex parent
  • End - rows are aligned to the bottom of the container
  • Stretch - rows stretch to fill empty vertical space
  • Space Between - rows are evenly distributed from top to bottom edges
  • Space Around - rows are evenly distributed between other rows and edges
Flexbox in Webflow

Flex child settings

A flex child is the direct child of any flex parent, any element that has its display layout set to flex. The default layout of flex children is based on the flex layout set on the flex container.

To configure the layout for a flex child within the flex parent, select the element and change the sizing, alignment, and display order.  

Change the size of a flex child

With the main sizing presets, you can tell the flex child how it should stretch in the flex parent. Each flex child can have its own size settings, allowing for a wide array of layout options:

  • Shrink flex child if needed (to prevent overflow)
  • Grow flex child if possible
  • Don’t shrink or grow flex child
  • Customize grow and shrink behavior

Customize grow and shrink behavior

If you choose to customize the grow and shrink behavior of an element, you’ll enter a number to determine how much the flex child will shrink or grow relative to other child elements.

Set the grow value to define how much a flex child can grow relative to other child elements when free space inside the parent element is distributed. If the value is set to 0, it won’t grow larger than it needs to.

Set the shrink value to define how much a flex child can shrink relative to other children when negative free space is distributed. If the value is set to 0, it won’t shrink even in overflow situations.

Set the basis value to define the default size of an element before flex grow or flex shrink come into play. You can set this to a specific dimension (e.g., 20%, 250px, etc.) or Auto. If set to Auto, the default size of a flex child will be based on its width or height (if set) or its content. If set to a specific dimension, the content or width/height of an element will be ignored before distributing size between flex children.

Change the order of a flex child

Reordering flex children comes in handy when you want mobile device users to see different content than users on desktop devices. By default, flex children display in the same order as they are placed in the source code. To override this, you can use the order setting presets or the custom order option.

Flex child order settings:
  • Don’t change: keep the flex child in its default place
  • First: the flex child appears first in the flex container
  • Last: the flex child appears last in the flex container
  • Customize order: control the display order of several flex children by defining a custom order value.
Flexbox in Webflow

Customize the order

Custom order can be defined as a number, which specifies the order in which the flex child appears inside a flex container. Flex children with the same custom order value will be laid out in the order they are placed originally.

When using custom order, do not use the presets to specify the first or last element in your list.  “First” sets the order of the flex child to -1, and “Last” sets the order to 1. When using custom order, any number greater than 1 will place the element after any element with order set to last. Any number smaller than -1 will place the element before any element set to first.

Also check out:

Try Webflow — it's free

Production for this lesson

Directed by


Produced by


Written by


Article by


Edited by


Designs by

Need more help? Want to report a bug? Contact support
Have feedback on the feature? Submit feature feedback