Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 37 ยท Layout and Design

Flexbox and Grid in the Builders

Understand flexbox and CSS grid, the two layout systems behind Webflow's Layout panel and Wix Studio's stacks and grids. Learn direction, alignment, gaps, fr units and when to use each.

Old websites were laid out with tables and floating boxes. Modern sites use two layout systems built into CSS: Flexbox for arranging items in a line (a row or a column) and Grid for arranging items in rows and columns. Webflow exposes both in its Layout section of the Style panel, as the display options Flex and Grid. Wix Studio presents the same ideas through stacks (flex-like) and grids. If you understand these two models, you understand how nearly every modern page is laid out.

This lesson teaches the concepts with plain descriptions and two stand-in calculators that perform the same arithmetic a browser does. The exact names of buttons and icons vary by tool and version, so we focus on what each setting means.

Flexbox: one dimension at a time

A flex container lays its children along a main axis. Set display: flex on the parent and its children become flex items.

flowchart LR
  subgraph Container["Flex container: direction row"]
    A["Item 1"] --- B["Item 2"] --- C["Item 3"]
  end

In a row, the main axis runs left to right and the cross axis runs top to bottom.

The key settings you will find in the Layout controls:

Setting CSS name What it does
Direction flex-direction Row (horizontal) or column (vertical) main axis
Horizontal / main-axis alignment justify-content Distribute items along the main axis: start, center, end, space-between, space-around
Vertical / cross-axis alignment align-items Align items across the main axis: start, center, end, stretch
Gap gap Space between items, without margins
Wrap flex-wrap Allow items to move to a new line when space runs out
Child grow / shrink / basis flex-grow, flex-shrink, flex-basis How an item shares free space

In Webflow, the labels swap meaning when you change direction: "horizontal" alignment refers to the main axis only in a row. Read the icons or hover for the tooltip, because the panel names the axes by screen direction.

How free space is shared

When items are smaller than the container, free space remains. justify-content decides where it goes. When items are larger than the container, they shrink (unless told not to) or wrap. When you give items flex-grow, free space is split between them in proportion to their growth values.

JS Stand-in: flex main-axis distribution

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Reading the output shows what each alignment option does to the same three items in a 600px container. This is exactly the arithmetic behind the alignment icons.

Flex patterns you will use constantly

  • Navigation bar: a row with justify-content: space-between and align-items: center, logo on one side, links on the other.
  • Centering anything: a container with justify-content: center and align-items: center.
  • A card with a pinned footer: a column in which the body has flex-grow: 1, pushing the footer to the bottom.
  • A responsive row of buttons: a row with flex-wrap: wrap and a gap.

Grid: two dimensions

CSS Grid divides a container into tracks: columns and rows. Items sit in cells, and may span several. It is ideal for page-level layouts and card galleries where alignment in both directions matters.

In Webflow's grid settings you define columns and rows with sizes such as:

  • A fixed size (200px).
  • A fraction of the free space: fr units (1fr, 2fr).
  • auto: sized by content.
  • minmax(min, max): flexible with limits.

A common gallery is three equal columns: 1fr 1fr 1fr. A common page layout is a sidebar plus content: 260px 1fr.

JS Stand-in: grid column widths with fr units

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Flexbox or Grid?

Use flexbox when Use grid when
Content flows in one direction You need rows and columns aligned together
Items have different sizes and should size to content You want an even layout with equal tracks
Distributing space along a line (nav, button groups) Page layouts, galleries, dashboards
You need wrapping that adapts to content You want items to span rows or columns

Both can be nested: a grid of cards, where each card is a flex column. In practice most pages use both.

Flexbox

One axis Row or column
Alignment Main and cross axis
Gap and wrap Spacing and line breaks

Great for navbars, button rows, card contents

1 / 2

Wix Studio's equivalents

Wix Studio's stacks behave like flex containers: they arrange children in a direction with spacing and alignment and let elements grow and shrink. Its grids behave like CSS grids with columns and rows you can size and place elements across. Containers and sections combine both. If you ever see a setting you do not recognise, ask whether it is a flex setting (direction, alignment, gap, wrap, grow) or a grid setting (tracks, spans). That question identifies almost every layout control.

The classic Wix Editor places elements more freely and relies on its own responsive logic, which can be easier to start with but gives less precise control as pages grow complex.

Common mistakes

  • Using margins for spacing between flex items instead of gap. Gap does not need first-or-last special cases.
  • Forgetting flex-wrap, so items squeeze or overflow on phones.
  • Fixed heights that cut off content.
  • Nesting too deeply. A grid inside a flex inside a grid is hard to maintain.
  • Not testing at several widths.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does justify-content control in a flex row?

    justify-content places items and distributes free space along the main axis.
  2. 2. With columns 1fr 2fr 1fr in a 1000px container and no gaps, how wide is the middle column?

    There are 4 fractions in total. Each fr is 250px, so 2fr is 500px.
  3. 3. When is grid usually a better choice than flexbox?

    Grid controls two dimensions at once, which suits gallery and page layouts.
  4. 4. What is the benefit of gap over margins for spacing items?

    Gap spaces items only between each other, so no first-or-last exceptions are needed.

Summary

  • Flexbox arranges items along one axis; grid arranges them in rows and columns.
  • Webflow exposes both in the Layout section; Wix Studio exposes them as stacks and grids.
  • Learn the axis idea (main versus cross), gap, wrap, grow and the fr unit.
  • Use flex for components and lines, grid for page structure and galleries, and nest sparingly.

Next: Wix Editor vs Wix Studio Layout