Building a Responsive Layout with Zurb Foundation’s XY Grid
Learn how to create a fully responsive page using Foundation’s XY Grid. The guide covers the desired outcome, prerequisites, markup steps, breakpoint checks, and recovery options if the layout breaks.
05 Nov 2025, 15:51 UTC

Desired Outcome
Produce a page that automatically adapts to the viewport width:
- Content sits inside a centered container.
- Rows divide the page into cells that stack vertically on small screens.
- Cells arrange side‑by‑side at medium and larger breakpoints, according to the 12‑column grid.
- All spacing comes from Foundation’s grid classes, eliminating the need for custom media queries.
Prerequisites
- A working HTML page that loads Foundation’s CSS (via CDN or a locally compiled Sass build). The example below uses the CDN link from
https://cdn.jsdelivr.net/npm/foundation-sites@6.7.5/dist/css/foundation.min.css. - Modern browser with developer tools (Chrome, Firefox, Edge).
- Basic knowledge of adding class attributes to HTML elements.
- If you plan to customize grid settings, a Sass pipeline that can compile
_settings.scssandfoundation.scss.
Procedure
- Wrap content in a container. Add the
grid-containerclass to a top‑level<div>so Foundation can center and constrain the layout.<div class="grid-container"> </div> - Create a row. Inside the container, add a
<div>withgrid-x. Choose eithergrid-margin-xfor gutters between cells orgrid-padding-xfor padding inside the row. Pick one and use it consistently.<div class="grid-x grid-margin-x"> </div> - Add cells. Inside the row, add child
<div>elements with thecellclass. Combinecellwith size classes to control column spans per breakpoint:small-12– full width on the smallest breakpoint.medium-6– two columns side‑by‑side on medium screens.large-4– three columns on large screens.
<div class="cell small-12 medium-6 large-4"> </div> - Optional: Nested rows. If a cell contains its own grid, nest a
grid-xinside the cell and apply the same rules.
Expected Checks
- Open the page in a browser, open the devtools
Responsive Design Mode, and resize the viewport across the named breakpoints:small(<650 px),medium(≥ 640 px),large(≥ 1024 px),xlarge(≥ 1200 px),xxlarge(≥ 1440 px). Verify that cells stack onsmalland lay out horizontally on larger sizes. - Inspect the computed styles for
grid-container,grid-x, andcellto ensure that padding/margin values match Foundation’s defaults. - Check the page width to ensure no horizontal scrollbar appears; the container should keep the layout centered.
- Verify that the stylesheet loaded is the version you expect (e.g., 6.7.5) by looking at the filename in the network tab or the comment block at the top of the CSS file.
Recovery Options
- Columns collapse incorrectly. Look for typos in class names (e.g.,
grid-xvs.grid-x), ensure each row hasgrid-x, and that it is inside agrid-container. - Gutters appear doubled. Remove any legacy
roworcolumnsclasses that add their own margins, and keep onlygrid-margin-xorgrid-padding-x. - A specific cell misbehaves. Temporarily set it to
small-12to force full width, then gradually re‑apply the desired size classes while testing. - Unexpected horizontal overflow. Check for any child elements with
width: 100vwor negative margins that exceed the container.
Engineering Decision Note
Foundation’s XY Grid is the recommended layout system in Foundation 6 and newer. It replaces the older float‑based and flex‑based grids, which are deprecated. However, Foundation’s development has slowed in recent years; it remains stable but may lack new features found in other modern frameworks. If you are starting a brand‑new project and need rapid iteration, consider frameworks that are actively maintained, but if you already rely on Foundation for other UI components, the XY Grid is a low‑change, reliable choice.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.