Foundation Grid Examples

Below we have collected some common examples of grids.


Three equal columns

This example demonstrates how to create three equal columns (33.3%/33.3%/33.3%), displaying three columns on medium and large devices, and automatically stacking on small devices:

Example

<div class="row">
  <div class="medium-4 columns" style="background-color:yellow;">
    <p>.medium-4</p>
  </div>
  <div class="medium-4 columns" style="background-color:pink;">
    <p>.medium-4</p>
  </div>
  <div class="medium-4 columns" style="background-color:yellow;">
    <p>.medium-4</p>
  </div>
</div>

Try it Yourself »

Three Unequal Columns

This example demonstrates how to create three unequal columns (25%/50%/25%), displaying three columns on medium and large devices, and automatically stacking on small devices:

Example

<div class="row">
  <div class="medium-3 columns" style="background-color:yellow;">
    <p>.medium-3</p>
  </div>
  <div class="medium-6 columns" style="background-color:pink;">
    <p>.medium-6</p>
  </div>
  <div class="medium-3 columns" style="background-color:yellow;">
    <p>.medium-3</p>
  </div>
</div>

Try it Yourself »

Two equal columns

This example demonstrates how to create two equal columns (50%/50%), where the column ratio is always 50%/50% on small, medium, and large devices:

Example

<div class="row">
  <div class="small-6 columns" style="background-color:yellow;">
    <p>.small-6</p>
  </div>
  <div class="small-6 columns" style="background-color:pink;">
    <p>.small-6</p>
  </div>
</div>

Try it Yourself »

Two Unequal Columns

This example demonstrates how to create two unequal columns (33.3%/66.6%), where the column ratio is always 33.3%/66.6% on small, medium, and large devices:

Example

<div class="row">
  <div class="small-8 columns" style="background-color:yellow;">
    <p>.small-8</p>
  </div>
  <div class="small-4 columns" style="background-color:pink;">
    <p>.small-4</p>
  </div>
</div>

Try it Yourself »

Change Column Order

by using.small|medium|large-push-*and.small|medium|large-pull-*Classes to modify the order of columns:

Example

<div class="row">
  <div class="small-4 small-8-push columns" style="background-color:yellow;">
    <p>.small-4 .small-8-push</p>
  </div>
  <div class="small-8 small-4-pull columns" style="background-color:pink;">
    <p>.small-8 .small-4-pull</p>
  </div>
</div>

Try it Yourself »

Nested columns

You can use nested grids (columns inside columns):

Example

<div class="row">
  <div class="small-8 columns">.small-8
    <div class="row">
      <div class="small-8 columns">.small-8 Nested
        <div class="row">
          <div class="small-8 columns">.small-8 Nested Again</div>
          <div class="small-4 columns">.small-4</div>
        </div>
      </div>
      <div class="small-4 columns">.small-4</div>
    </div>
  </div>
  <div class="small-4 columns">.small-4</div>
</div>

Try it Yourself »

Mixed: mobile, desktop devices

The Foundation grid system has three columns:.small-*(phone),.medium-*(Tablet), and.large-*(desktop devices). These classes can be dynamically combined to make the layout more flexible:

Tip:Each class can be scaled up. If you want the width to be the same on small and large screen devices, you can set the specified.small-*。

Example

<div class="row">
  <div class="small-6 large-8 columns">.small-6 .large-8</div>
  <div class="small-6 large-4 columns">.small-6 .large-4</div>
</div>
<div class="row">
  <div class="small-2 large-4 columns">.small-2 .large-2</div>
  <div class="small-4 large-4 columns">.small-4 .large-2</div>
  <div class="small-6 large-4 columns">.small-6 .large-2</div>
</div>
<div class="row">
  <div class="small-3 large-5 columns">.small-3 .large-5</div>
  <div class="small-9 large-7 columns">.small-9 .large-7</div>
</div>

Try it Yourself »

Mixed: mobile, tablet, and desktop devices

Example

<div class="row">
  <div class="medium-6 large-8 columns">.medium-6 .large-8</div>
  <div class="medium-6 large-4 columns">.medium-6 .large-4</div>
</div>
<div class="row">
  <div class="small-4 medium-3 large-7 columns">.small-4 .medium-3 .large-7</div>
  <div class="small-4 medium-6 large-3 columns">.small-4 .medium-6 .large-3</div>
  <div class="small-4 medium-3 large-2 columns">.small-4 .medium-3 .large-2</div>
</div>

Try it Yourself »

Centered columns

Column centering can be used.small-centeredclass. Medium and large devices can inherit the centering from small devices, but you need to set the centering class on large devices..large-centered 。

Example

<div class="row">
  <div class="small-4 small-centered columns">small-4 small-centered</div>
</div>
<div class="row">
  <div class="small-6 small-centered columns">small-6 small-centered</div>
</div>
<div class="row">
  <div class="small-6 large-centered columns">small-6 large-centered</div>
</div>
<div class="row">
  <div class="small-8 small-centered large-uncentered columns">small-8 small-centered large-uncentered</div>
</div>
<div class="row">
  <div class="small-10 small-centered columns">small-10 small-centered</div>
</div>

Try it Yourself »

Column offset

You can use.large-offset-*(or.small-offset-*) class moves the column to the right. The number of columns for the left margin is controlled by the * sign:

Example

<div class="row">
  <div class="large-1 columns">1</div>
  <div class="large-11 columns">11</div>
</div>
<div class="row">
  <div class="large-1 columns">1</div>
  <div class="large-10 large-offset-1 columns">10, offset 1</div>
</div>
<div class="row">
  <div class="large-1 columns">1</div>
  <div class="large-9 large-offset-2 columns">9, offset 2</div>
</div>
<div class="row">
  <div class="large-1 columns">1</div>
  <div class="large-8 large-offset-3 columns">8, offset 3</div>
</div>

Try it Yourself »

Incomplete columns

If the total number of columns in a row is not 12, Foundation will automatically float the last column to the right and use blank space to fill the remaining columns.

Optional.endclass is used to float the element in the last column to the left:

Example

<div class="row">
  <div class="medium-3 columns">.medium-3</div>
  <div class="medium-3 columns">.medium-3</div>
  <div class="medium-3 columns">.medium-3</div>
</div>
<div class="row">
  <div class="medium-3 columns">.medium-3</div>
  <div class="medium-3 columns">.medium-3</div>
  <div class="medium-3 columns end">.medium-3 .end</div>
</div>
Try it Yourself »

Widescreen

Grid (.row) The maximum size (max-width) is 62.5rem. On wide-screen devices, the size may be greater than 62.5rem, so the columns cannot fully fill the page, even if the width is set to 100%. But we can set a new max-width via CSS:

Example

<style>
.row {
    max-width: 100%;
}
</style>

Try it Yourself »

If you want to use the default max-width, but the background color needs to span the entire page, then you use it on the container element.rowClasses, and specify the background color you need:

Example

<div style="background-color:coral;padding:25px;">
  <div class="row">
    <div class="small-6 columns" style="background-color:yellow;">.small-6</div>
    <div class="small-6 columns" style="background-color:pink;">.small-6</div>
  </div>
</div>

Try it Yourself »
other extensions