Flexbox Cheatsheet
For Divi 5 users

Flexbox Cheatsheet

Layout is one of the biggest changes from Divi 4 to Divi 5. Sections, rows, columns and groups now have a setting called Layout Style, with three choices. This page covers Flex, which uses something called flexbox. It shows you, in plain English, what each setting does before you touch it in the builder.

Block

How Divi 4 worked. Each thing stacks under the one before. Pages and layouts brought over from Divi 4 may still use it.

Flex This page

Lines things up in one direction, side by side or stacked. If they wrap onto a new line, each line is arranged on its own. New pages in Divi 5 start here.

Grid

Lines things up in rows and columns at the same time, like a gallery or a set of pricing cards.

Open the Grid Cheatsheet

So what is flexbox?

Picture a shelf with a few ornaments on it. You can line them up left to right or stack them. You can bunch them together at one end, spread them out evenly, or put them in the middle. If there are too many, you can let some move down to the shelf below.

Flexbox is simply a set of rules for doing that on a web page. In Divi, the shelf is your row, column or group, and the ornaments are the modules inside it. You choose the rules on the shelf, and everything on it follows them.

Which way they line up

Side by side in a row, or stacked in a column.

In Divi: Layout Direction

How the space is shared

Bunched at the start, in the middle, at the end, or spread out.

In Divi: Justify Content

Where they sit the other way

Lined up along the top, the middle, the bottom, or stretched to fill.

In Divi: Align Items

An easy way to look at it

Justify Content follows the direction your modules are lined up in. Align Items works the other way.

In a row (side by side), Justify Content moves modules left and right. Align Items moves them up and down.

In a column (stacked), they swap. Justify Content moves modules up and down. Align Items moves them left and right.

So if Justify Content seems to move things the wrong way, check your Layout Direction first.

Try it before you build it

The grey area below is your shelf, and the lettered blocks are modules. The settings on the right use the same names as Divi 5. Click one and watch what happens. The box under the shelf tells you what you're seeing and why. Click a block to change settings for that block on its own.

The blocks are different sizes on purpose, just like real modules. A short heading, a tall image and a button are rarely the same size on your page. Here you can see how to line them up in a way that works for you.

This playground is easiest to use on a tablet or computer, where you can see the settings and the results side by side. On a phone, the settings scroll in their own box just under the blocks.

What you're seeing

Show the code behind this (optional)

You never need this in Divi. The builder writes it for you. It's here if you're curious.

Shelf settings

Design tab, Layout in Divi

Scroll this panel for more settings. The shelf stays where it is.


Block B on its own

Click any block to pick it. In Divi, these live in the module’s own settings.


The settings at a glance

Divi settingIn plain EnglishWatch out for
Layout StyleFlex turns on everything on this page. Block is the older way, where things simply stack.The other settings only appear when Flex is chosen.
Layout DirectionLine modules up side by side (Row) or stacked (Column). Reverse flips the order.Changing this swaps what Justify Content and Align Items do.
Justify ContentHow empty space is shared out in the direction your modules are lined up.No empty space means no visible change. In a column, give the container a height first.
Align ItemsWhere modules sit in the other direction: start, middle, end, or stretched to fill.A fixed width or height on a module stops Stretch working.
Layout WrappingWhether modules move onto a new line when they run out of room.No Wrap squeezes them instead, which can make things look cramped.
Wrapping AlignmentHow the lines themselves are spaced, once modules have wrapped.Only appears when wrapping is turned on, and needs two or more lines.
Horizontal and Vertical GapThe space between modules, side to side and top to bottom.Adds space between items only, not around the outside. Divi's default unit is %.
OrderOn a single module (Content tab). Moves it earlier or later on screen without dragging it.Screen readers still read the original order, so use it sparingly.
Sizing: AlignmentOn a single module. Lines that one module up at the start, middle or end, ignoring Align Items.Only appears once the module has a Width or Max Width.
Sizing: SizeOn a single module. Grow to Fill makes it take up the empty space. Shrink to Fit is the normal behaviour.A module set to Grow to Fill uses up the empty space, so Justify Content has nothing left to move.

Common layouts and what to choose

Every layout here uses flexbox, because the modules only need to line up in one direction, side by side or stacked, even when they wrap. When you need proper rows and columns at the same time, like a gallery, a pricing table or a team page, that’s a job for grid. See the Grid Cheatsheet.

Image and text, alternating sides

  • First row: Layout DirectionRow
  • Next row: Layout DirectionRow Reverse
  • Align ItemsCenter
  • Phone view: Layout DirectionColumn

Build every row with the image first. Row Reverse swaps the sides on desktop, and Column on phones puts the image on top every time, so you never have to rebuild a row to change the order.

Card buttons all level at the bottom

  • Row: Align ItemsStretch
  • Each card group: DirectionColumn
  • Each card group: JustifySpace Between

Stretch makes the cards equal height. Space Between pushes each button down to the bottom.

Three on top, two centred below

  • Layout DirectionRow
  • Layout WrappingWrap
  • Justify ContentCenter
  • Each module: Sizing › Width30%
  • Horizontal Gap5%

Three widths of 30% plus two gaps of 5% add up to 100%, so the fourth module drops to a new line. Center then puts the last two in the middle. Leave Size on Shrink to Fit, or the bottom two will stretch wider than the top three.

Centre something in a section

  • Layout DirectionColumn
  • Justify ContentCenter
  • Align ItemsCenter

Give it a Min Height under Sizing, so there's room to centre in.

Two buttons side by side

  • Layout DirectionRow
  • Justify ContentStart or Center
  • Align ItemsCenter
  • Phone view: Layout DirectionColumn

Put both buttons in a Group and set these on the Group. "Book a call" and "Learn more" then sit together on desktop and stack neatly on phones instead of squashing.

Cards that drop onto new lines

  • Layout DirectionRow
  • Layout WrappingWrap
  • Horizontal and Vertical GapSame value

For a set number per row on tablet and phone, use Change Column Structure instead.

"I clicked it and nothing happened"

  • Justify Content does nothing

    It can only share out empty space. If your modules already fill the row, there's nothing to move. In a column, the container also needs a height taller than its contents.

  • Stretch doesn't stretch

    A module with its own fixed width or height keeps that size. Take the fixed size off and Stretch will work.

  • I can't find Wrapping Alignment

    It only appears once Layout Wrapping is set to Wrap. Even then you need two or more lines of modules to see it.

  • Everything moved the wrong way

    You probably changed Layout Direction. Switching between row and column swaps what Justify Content and Align Items do.

  • My modules look squashed

    With No Wrap, modules shrink to fit on one line. Turn on Wrap so they can move onto the next line.

  • It looks right on desktop, wrong on phone

    Phones have less space, so spacing choices behave differently. Check each setting in Divi's tablet and phone views.

Moving from Divi 4 to Divi 5?

If you want to migrate to Divi 5 with confidence, and get to grips with the new interface and new features, have a look at Rocking Divi 5.

Find out about Rocking Divi 5
Not sure if you need flex or grid? Take a look at the Grid Cheatsheet. Divi setting names checked against Elegant Themes' own guides: Understanding every flexbox setting in Divi 5 and Understanding Divi's new flexbox layout.