Flexbox and Grid Layouts
|
This content was generated with the assistance of AI and should be verified against the official Webflow documentation before being relied on in production. This sub-section’s Webflow bibliography lists the reference material consulted while preparing these pages. |
This page was written against the Webflow Designer as it was on 2026-10-28. Layout controls are available on every plan, including the free Starter Site plan, so every example here can be built without paying. Webflow is a hosted service without version numbers, so the exact labels in the Style panel can move between visits; the CSS properties they write do not, because they are standard CSS.
Layout is the part of a Webflow project where the visual tool and the web platform meet most directly. The Layout section of the Style panel has a Display setting, and choosing Flex or Grid there turns an element into a flexbox or grid container whose children are arranged by the browser, not by absolute coordinates. Behind the buttons there is no proprietary layout engine: Webflow writes the standard display, flex-*, grid-*, gap and alignment properties into the site stylesheet. This page explains each control, shows the CSS that it generates, and gives a rule for choosing between Flex, Grid and Quick Stack. The underlying CSS is described in Layout: Float, Flexbox and Grid; the box model that every layout depends on is in Style panel and box model; the elements that become containers are introduced in Elements and page structure.
The running example is the Fernbrook Gardens site, a fictitious botanical garden. Three layouts are built on its pages: the navigation bar and a row of ticket buttons (one-dimensional, so Flex), the events gallery with a featured event (two-dimensional, so Grid), and a two-column "Visit us" block (Quick Stack).
Display values in the Style panel
The Display control of the Layout section accepts these values: Block, Flex, Grid, Inline, Inline block, Inline flex, Inline grid, None and, in the current Designer, Contents. The ones that matter for layout are Flex and Grid; None hides the element at the selected breakpoint and is the basis of the show-and-hide patterns described in Responsive design and breakpoints.
.cards-row {
display: flex;
}
.events-gallery {
display: grid;
}
Two ideas apply to both layouts:
-
A container controls its direct children only. Setting Flex on a Section does not affect the grandchildren inside a Container; each nested level that needs its own arrangement needs its own Display setting. Deep nesting of Flex and Grid containers is normal, but the Navigator should stay readable.
-
When an element becomes a flex or grid container, the Style panel adds a second group of controls that apply to its children: Flex child or Grid child. These write properties on the child’s own class, so the same element can be a container for its content and a flex or grid item of its parent at once.
Choosing between Flex, Grid and Quick Stack
The rule of thumb that most layout tutorials give, and that Webflow’s own Help Center repeats, is that Flex arranges items along one axis and Grid arranges them along two. Quick Stack is a preset: an element that is created as a ready-made grid whose cells are flex containers, intended for the very common case of two or three blocks side by side that stack on small screens.
The chart is a schematic of a decision, not a screenshot. Three practical consequences follow from it.
-
A navigation bar, a button group, a card with an icon next to a title, or a footer link list is a one-dimensional arrangement, and Flex gives the best control: items can be pushed to the ends with auto margins, aligned on the cross axis, and wrapped when they no longer fit.
-
A gallery of cards, a pricing table, a dashboard or any page-level skeleton with a header, sidebar and content is two-dimensional, and Grid is the natural fit because the rows and columns line up across items. Doing the same with nested flex rows needs workarounds that Grid does not.
-
A very common mistake is to use Flex with percentage widths to imitate a grid and then fight the gaps and wrapping. When the items should line up in columns across rows, switch to Grid.
The two layouts can be combined without friction: a Grid for the page skeleton and a Flex row inside a grid cell for a toolbar is the usual structure. The older book Webflow by Example states the same Flex-for-one-dimension and Grid-for-two-dimensions rule; what has changed since is the interface (Grid and Quick Stack controls are much richer than in 2021) and the availability of Quick Stack, which did not exist.
Flex layouts
Choosing Flex for an element writes display: flex and shows the flex container controls in the Layout section. Flex works on a main axis (the direction items flow in) and a cross axis (perpendicular to it). Almost every Flex control is either about the main axis or about the cross axis, and confusing the two is the usual source of "why is it not centered" questions.
Direction
The direction control offers four buttons: horizontal, vertical, and the two reversed variants (right to left and bottom to top).
| Designer setting | CSS property | Effect |
|---|---|---|
Horizontal |
|
Items flow left to right; this is the default |
Vertical |
|
Items flow top to bottom |
Horizontal reversed |
|
Items are drawn right to left without changing the HTML order |
Vertical reversed |
|
Items are drawn bottom to top without changing the HTML order |
The reversed directions change only how the page is drawn. Keyboard focus order and screen readers still follow the HTML order, so reversing a form or a list can make the focus jump around the screen. The same caution applies to the Order setting described below.
Wrap
By default a flex row does not wrap: when the items are wider than the container, they shrink and, once they cannot shrink further, overflow. The wrap control has three options, labelled in the Designer as No wrap, Wrap and Reverse wrap. They map to flex-wrap: nowrap, wrap and wrap-reverse. A wrapping row gains a second alignment control, align content, for distributing the lines when the container is taller than the lines it holds.
Justify and align
The justify and align controls are drawn as rows of icon buttons, and their meaning depends on the direction.
| Control | CSS property | Axis in a horizontal row |
|---|---|---|
Justify |
|
The main axis: horizontal |
Align items |
|
The cross axis: vertical |
Align content |
|
The cross axis, but only when items wrap onto several lines |
In a vertical container the axes swap: Justify controls the vertical distribution and Align controls the horizontal alignment. Webflow redraws the icons to match the direction, which is a useful reminder when a button seems to do the opposite of what its label says.
Gap
The gap control sets the space between children and is available on both Flex and Grid. It writes the gap property (row and column gap), so the spacing exists only between items and not before the first or after the last. This is the main reason to prefer gap to margins on children: removing or hiding an item does not leave a stray margin behind, and wrapped lines get the vertical spacing for free. Row gap and column gap can be set independently by unlinking the two fields. Values can be written in px, rem, em or % or bound to a size variable, so a spacing scale shared by the whole site can drive every gap (see Variables and modes).
The generated CSS for a flex container
For the Fernbrook Gardens header, a nav-bar class set to Flex, horizontal, justify space-between, align center, wrap and a 24 pixel gap produces a rule of this shape in the published stylesheet:
.nav-bar {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 24px;
}
Source: Webflow Help Center: Flexbox
Webflow only writes a property when it differs from the initial value of the browser, or when it overrides a larger breakpoint; the order of declarations in the published file is not significant.
Flex child: sizing, alignment and order
Selecting a child of a flex container shows the Flex child section. It has three groups of controls.
Sizing has four presets and a custom mode:
| Preset | Meaning | CSS written |
|---|---|---|
Shrink if needed |
The child keeps its own width or content size and may shrink when space runs out |
|
Grow if possible |
The child takes a share of any free space |
|
Don’t shrink or grow |
The child is fixed and never resizes |
|
Custom |
Separate Grow, Shrink and Basis fields |
|
Grow and shrink are relative numbers: two siblings with grow 1 and 2 split the free space one-third and two-thirds, and a value of 0 switches the behavior off. Basis is the starting size before grow and shrink are applied, either a length or Auto, which means the width or height of the element (or its content when none is set). The exact shorthand that the Designer writes can be a long-hand set of properties rather than a single flex declaration; the effect is identical.
Alignment overrides the container’s cross-axis alignment for one child (align-self) with the options Auto, Top, Center, Bottom, Stretch and Baseline (the names rotate in a vertical container). Setting a margin to auto on one side of a child pushes it away from its siblings, which is the usual way to put a "Buy tickets" button on the right of a navigation bar while the logo and links stay on the left.
Order offers Don’t change, First, Last and Customize order, which writes the order property. Items with the same order value keep their HTML order. Like the reversed directions, Order changes only the visual sequence and not the focus or reading order, so use it for cosmetic rearrangement (for example, moving an image above the text on mobile) and not for content whose sequence carries meaning.
.nav-links {
display: flex;
gap: 16px;
}
.nav-cta {
margin-left: auto;
flex: 0 0 auto;
}
.hero-photo {
order: -1;
}
A flex recipe: a ticket-button row
The Fernbrook Gardens ticket buttons are three links of different lengths that should sit in a row on desktop, wrap on narrow screens and share the leftover space.
-
Select the
ticket-buttonsDiv Block and set Display to Flex in the Layout section. -
Set the direction to horizontal, enable Wrap and set the gap to
12px. -
Select each
ticket-buttonlink and, under Flex child sizing, choose Custom with Grow1, Shrink1and Basis180px. -
Open the Tablet and Mobile breakpoints and check the result. No change is needed: with a basis of 180 pixels the buttons wrap when two no longer fit, and the grow value lets each line fill its width.
.ticket-buttons {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.ticket-button {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 180px;
}
Source: Webflow Help Center: Flexbox
This pattern is "intrinsic" responsive design: the layout adapts because of how the sizes are defined and not because a media query changes them, which is cheaper to maintain than three sets of breakpoint overrides.
Grid layouts
Choosing Grid for an element writes display: grid and a default of two columns and two rows. A grid divides the container into tracks, which are the columns and the rows; the places where a column and a row intersect are cells; and the children are placed in cells in source order unless told otherwise. The Designer also has a grid edit mode, entered from the Layout section or by clicking the grid on the canvas, which draws the tracks over the page and lets you click a track header to edit it.
Tracks and units
A track size can be written in several units, each of which is a different promise to the browser.
| Unit | Behavior |
|---|---|
|
A fixed size; use for tracks that must not change, such as a sidebar of |
|
A fraction of the free space after fixed tracks and gaps are subtracted; |
|
A percentage of the grid container; gaps are not accounted for, so the total can overflow |
Auto |
The track sizes itself to its content |
Custom |
Any valid track expression, for example |
A minimum and maximum can be set on a track in grid edit mode, which writes minmax(). This is how a column is told "never narrower than 240 pixels, but share the space otherwise". The fr unit is the workhorse of Grid layouts because it avoids the arithmetic of percentages and gaps.
Auto-fit: columns that adapt without breakpoints
For card galleries, a fixed number of columns requires a breakpoint override for every screen width. Webflow supports the CSS technique that avoids this. To switch it on, reduce the grid to one column and one row, click the column header in grid edit mode, set a minimum and a maximum size for the column (for example 240 pixels and 1fr) and check Auto-fit. Webflow then writes a repeating track definition, and the browser decides how many columns fit.
.events-gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 24px;
}
Source: Webflow Help Center: Grid
At a container width of 1200 pixels the Fernbrook events gallery shows four columns, at 600 pixels two, and on a phone one, with no breakpoint override. auto-fit collapses empty tracks so that the cards stretch to fill the row, while auto-fill (the alternative in CSS) would keep the empty tracks and leave blank space at the end. Rows are created automatically as items are added.
Rows and automatic placement
With the default placement the grid fills cells from left to right and, when a row is full, creates a new one. The rows setting works like columns; the extra rows that the grid creates by itself are sized by the implicit row size (grid-auto-rows), which can be set to auto, a fixed height or a minmax() such as minmax(200px, auto) so cards have a uniform minimum height but grow with their content. A page built on implicit rows is more robust against CMS content of unpredictable length than one with fixed rows.
Spans and manual placement
Selecting a child of a grid container shows the Grid child section. Its Position controls place the item by line numbers or by spanning.
-
Span makes the item cover several columns or rows: the featured event on the Fernbrook events page spans two columns and two rows, so the next cards flow around it.
-
Manual start and end set the exact lines, for example column 1 to 3 and row 2 to 3. Negative numbers count from the end, so row
-1is the last row even when the grid gains rows. -
Align and justify self override the alignment inside the cell for one child.
.event-featured {
grid-column: span 2;
grid-row: span 2;
}
.event-footer-banner {
grid-column: 1 / -1;
}
Source: Webflow Help Center: Grid
The grid line numbering starts at 1 on the left or top edge, so a grid with three columns has four vertical lines; 1 / -1 therefore means "from the first line to the last line", which is the full width whatever the number of columns.
Grid areas
Grid areas give names to rectangular regions of the grid. In grid edit mode, drag across cells to define an area and name it; children can then be assigned to the area, and an area-based layout can be rearranged by redefining the areas instead of moving every child. Deleting an area moves its children to automatically generated rows and columns. The generated CSS is the standard grid-template-areas property on the container and grid-area on the children.
.page-skeleton {
display: grid;
grid-template-columns: 280px 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header"
"sidebar content"
"footer footer";
gap: 24px;
}
.site-header { grid-area: header; }
.site-sidebar { grid-area: sidebar; }
.site-content { grid-area: content; }
.site-footer { grid-area: footer; }
Source: Webflow Help Center: Grid areas
Areas make the layout readable in the stylesheet as well: the picture of the page is visible in the strings. They are especially useful for responsive reflow, because a mobile breakpoint can declare a single-column set of areas that places the sidebar after the content.
Quick Stack
Quick Stack is an element in the Add panel that inserts a ready-made, responsive arrangement of blocks. It is a Grid container whose cells are Flex containers (columns by default). Webflow’s Help Center describes it as the combination of the two layout systems: the grid gives equal-width columns that stack on small screens, and each cell is a flex container to which the content is added.
-
A new Quick Stack contains two cells; extra cells can be added or removed from the element’s settings or by dragging.
-
Its grid controls (columns, rows, gap) are those of any other Grid, and the cells can be restyled like any other element.
-
On smaller breakpoints the grid reflows: the rows value shows Auto and fills itself from the column setting so the cells stack, and each cell can be resized and made to span several rows or columns in the Cell size panel.
-
The result is ordinary markup: a
divcontainer withdivchildren, styled by classes, with no JavaScript.
<div class="w-layout-layout quick-stack">
<div class="w-layout-cell">
<h2>Opening hours</h2>
<p>Daily from 9:00 to 18:00.</p>
</div>
<div class="w-layout-cell">
<h2>Getting here</h2>
<p>Bus 14 stops at the main gate.</p>
</div>
</div>
Source: Webflow Help Center: Quick Stack
The class names above are illustrative of Webflow’s built-in layout classes; the exact names and the amount of generated CSS can differ between Designer versions, so check the published code (see HTML and CSS in Webflow) instead of relying on the names.
Use Quick Stack when the content is a handful of blocks side by side and the default stacking behavior is what is wanted. Use Flex when the items need alignment control or wrapping, and Grid when the layout needs tracks, areas or spans. A Quick Stack is not locked: if the preset becomes too limiting, its container can be restyled as a regular Grid.
Responsive reflow
Layouts change at breakpoints because the Display, direction, wrap, gap and track definitions can all be overridden per breakpoint. The cascade rules that apply (desktop as the base, smaller breakpoints cascading down, larger ones cascading up) are described in Responsive design and breakpoints. For layout the useful patterns are:
| Situation | Flex solution | Grid solution |
|---|---|---|
Cards in a row on desktop, stacked on mobile |
Wrap with a basis, or switch direction to vertical on Mobile portrait |
Change the columns to one |
Sidebar beside content on desktop |
Flex row with a fixed-basis sidebar; switch to vertical on Tablet |
Two tracks |
Image above text on mobile only |
Order |
Redefine the areas so the image area comes first |
Fewer decorative items on small screens |
Display None on the extra items |
Display None, or fewer tracks with a smaller gap |
.events-gallery {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 24px;
}
@media screen and (max-width: 991px) {
.events-gallery {
grid-template-columns: 1fr 1fr;
}
}
@media screen and (max-width: 479px) {
.events-gallery {
grid-template-columns: 1fr;
gap: 16px;
}
}
Source: Webflow Help Center: Grid
The max-width values come from Webflow’s default breakpoints (991 pixels for Tablet, 767 for Mobile landscape and 478 for Mobile portrait); the code above uses the common Tablet and Mobile portrait pair. Because breakpoints are max-width queries cascading downward, a value set on Tablet also applies to the smaller widths unless it is overridden again.
Layout with the CMS
A Collection list is a container of repeated items, and it takes the same Display settings: a Collection List Wrapper can be set to Grid or Flex so that the CMS items form a gallery, which is the way the Fernbrook events gallery is built. The layout controls apply to the Collection list element, not to the collection item, so a Grid on the list arranges the items as cells. Auto-fit grids are particularly good for CMS content because the number of items changes. Collection lists are described in Collection lists.
Developer notes
-
Inspecting the result. The published page contains the CSS of every class used. In the browser developer tools, the Layout tab of Chrome and Firefox shows grid lines, track sizes and flex alignment overlays, which is the fastest way to understand a layout that does not behave.
-
Custom CSS. Properties the Style panel does not expose (for example
grid-template-columnswithsubgrid, or container queries) can be added with a custom CSS embed in the head or with an Embed element; see Custom code in the head, footer and embeds. -
Browser support. Flexbox, Grid and gap are supported by every browser that Webflow supports for published sites; no prefixes are required in current browsers.
-
Designer API. Display and flex or grid properties can be read and written through the style API of the Designer extensions, which use the same property names as CSS (see Designer extensions and the Designer API).
Common mistakes and pitfalls
-
Mixing up the axes. If centering seems to do the opposite, check the direction; Justify follows the main axis and Align the cross axis.
-
Margins instead of gap. Margins on children leave a trailing space, double up when items wrap and do not disappear with a hidden item. Use gap.
-
Percentage widths on flex children. They fight with gap and shrinking. Prefer basis and grow.
-
Fixed row heights in a CMS grid. Content of unpredictable length overflows a fixed row. Let rows size automatically or use
minmax(). -
Setting the layout on the wrong element. The Display of a parent arranges its children only. If nothing happens, select the parent, not the child.
-
Reordering for visual effect only. Reverse directions and Order do not change the focus order. Keep the HTML order the same as the logical order and check keyboard navigation (see Accessibility).
-
Forgetting that grid edits are per breakpoint. Changing a track on Desktop does not change a value that was already overridden on Tablet. The orange label on a field tells that the value is set on the current breakpoint.
-
Deleting a grid area carelessly. Children assigned to it move to automatically generated rows and columns.
Corrections to older tutorials
Ali Rushdan Tariq’s Webflow by Example (Packt, 2021) teaches layout with Flexbox for one dimension and Grid for two, which is still the right rule and is kept on this page. Its click paths are from before the 2023 Designer redesign, its Grid chapter predates auto-fit, grid areas, Position by line numbers and negative indexes, and Quick Stack did not exist. Where the book builds multi-column sections by nesting Flex rows with percentage widths, a Grid or a Quick Stack is now the simpler choice.