Skip to main content
Figuration v3 Preview Available!
Layout

Options for structuring your pages, including global styles, required scaffolding, grid system, and more.

Grid System

Figuration includes a powerful mobile-first grid system for building layouts of all shapes and sizes. It’s based on a 12 column layout and has multiple tiers, one for each media query range. You can use it with Sass mixins or our predefined classes.

Contents

How It Works

At a high level, here’s how the grid system works:

  • There are three major components—containers, rows, and columns.
  • Containers—.container for fixed width or .container-fluid for full width—center your site’s contents and help align your grid content.
  • Rows are horizontal groups of columns that ensure your columns are lined up properly.
  • Content should be placed within columns, and only columns may be immediate children of rows.
  • Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So if you want three equal-width columns, you’d use .col-4.
  • Column widths are set in percentages, so they’re always fluid and sized relative to their parent element.
  • Columns have horizontal padding to create the gutters between individual columns.
  • You can remove the margin from rows and padding from columns with .no-gutters on the .row.
  • There are five grid tiers, one for each responsive breakpoint: extra small, small, medium, large, and extra large.
  • Grid tiers are based on minimum widths, meaning they apply to that one tier and all those above it (e.g., .col-sm-4 applies to small, medium, large, and extra large devices).
  • You can use predefined grid classes or Sass mixins for more semantic markup.

Sounds good? Great, let’s move on to seeing all that in an example.

Quick Start Example

If you’re using Figuration’s compiled CSS, this the example you’ll want to start with.

1 of 3
1 of 3
1 of 3
<div class="container">
  <div class="row">
    <div class="col-sm-4">
      1 of 3
    </div>
    <div class="col-sm-4">
      1 of 3
    </div>
    <div class="col-sm-4">
      1 of 3
    </div>
  </div>
</div>

The above example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent .container.

Grid Options

See how aspects of the Figuration grid system work across multiple devices with this handy table.

The example pixel values are calculated based upon assumption where the average user has a 16px root font size.

Extra small
<576px
<36em
Small
≥576px
≥36em
Medium
≥768px
≥48em
Large
≥992px
≥62em
Extra large
≥1200px
≥75em
Grid behavior Horizontal at all times Collapsed to start, horizontal above breakpoints
Max container width None (auto) 544px (33.75rem) 720px (45rem) 960px (60rem) 1152px (72rem)
Class prefix .col- .col-sm- .col-md- .col-lg- .col-xl-
# of columns 12
Gutter width 2rem / 32px (16px on each side of a column)
Nestable Yes
Offsets Yes
Column ordering Yes

Predefined Classes

In addition to our semantic mixins, Figuration includes an extensive set of prebuilt classes for quickly creating grid columns. It includes options for device-based column sizing, reordering columns, and more.

Example: Stacked-to-horizontal

Using a single set of .col-md-* grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns in any .row.

.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-8
.col-md-4
.col-md-4
.col-md-4
.col-md-4
.col-md-6
.col-md-6
<div class="row">
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-6">.col-md-6</div>
  <div class="col-md-6">.col-md-6</div>
</div>

Example: Mobile and Desktop

Don’t want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding .col-* and .col-md-* to your columns. See the example below for a better idea of how it all works.

.col-12 .col-md-8
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6
.col-6
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
  <div class="col-12 col-md-8">.col-12 .col-md-8</div>
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>

<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>

<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
  <div class="col-6">.col-6</div>
  <div class="col-6">.col-6</div>
</div>

Example: Mobile, Tablet, Desktop

Build on the previous example by creating even more dynamic and powerful layouts with tablet .col-sm-* classes.

.col-12 .col-sm-6 .col-md-8
.col-6 .col-md-4
.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
<div class="row">
  <div class="col-12 col-sm-6 col-md-8">.col-12 .col-sm-6 .col-md-8</div>
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>
<div class="row">
  <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
  <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
  <!-- Optional: clear the XS cols if their content doesn't match in height -->
  <div class="clearfix hide-sm-up"></div>
  <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
</div>

Example: Remove Gutters

The gutters between columns in our default, predefined grid classes can be removed with .no-gutters. This removes the negative margins from .row and the horizontal padding from all immediate children columns.

Here’s the source code for creating these styles. Note that column overrides are scoped to only the first children columns and are targeted via attribute selector. While this generates a more specific selector, column padding can still be further customized with spacing utilities.

.no-gutters {
    margin-right: 0;
    margin-left: 0;

    > [class*="col-"],
    > .col {
        padding-right: 0;
        padding-left: 0;
    }
}

In practice, here’s how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).

.col-12 .col-sm-6 .col-md-8
.col-6 .col-md-4
<div class="row no-gutters">
  <div class="col-12 col-sm-6 col-md-8">.col-12 .col-sm-6 .col-md-8</div>
  <div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>

Example: Column Wrapping

If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.

.col-9
.col-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
.col-6
Subsequent columns continue along the new line.
<div class="row">
  <div class="col-9">.col-9</div>
  <div class="col-4">.col-4<br>Since 9 + 4 = 13 &gt; 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
  <div class="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
</div>

Example: Responsive Column Resets

With the four tiers of grids available you’re bound to run into issues where, at certain breakpoints, your columns don’t clear quite right as one is taller than the other. To fix that, use a combination of a .clearfix and our responsive utility classes.

.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
<div class="row">
  <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
  <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>

  <!-- Add the extra clearfix for only the required viewport -->
  <div class="clearfix hide-sm-up"></div>

  <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
  <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
</div>

In addition to column clearing at responsive breakpoints, you may need to reset offsets, pushes, or pulls. See this in action in the grid example.

.col-sm-5 .col-md-6
.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
.col-sm-6 .col-md-5 .col-lg-6
.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
<div class="row">
  <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
  <div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
</div>

<div class="row">
  <div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
  <div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
</div>

Example: Offsetting Columns

Move columns to the right using .offset-md-* classes. These classes increase the left margin of a column by * columns. For example, .offset-md-4 moves .col-md-4 over four columns.

.col-md-4
.col-md-4 .offset-md-4
.col-md-3 .offset-md-3
.col-md-3 .offset-md-3
.col-md-6 .offset-md-3
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
</div>
<div class="row">
  <div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
  <div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
</div>
<div class="row">
  <div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
</div>

Example: Nesting Columns

To nest your content with the default grid, add a new .row and set of .col-sm-* columns within an existing .col-sm-* column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).

Level 1: .col-sm-9
Level 2: .col-8 .col-sm-6
Level 2: .col-4 .col-sm-6
<div class="row">
  <div class="col-sm-9">
    Level 1: .col-sm-9
    <div class="row">
      <div class="col-8 col-sm-6">
        Level 2: .col-8 .col-sm-6
      </div>
      <div class="col-4 col-sm-6">
        Level 2: .col-4 .col-sm-6
      </div>
    </div>
  </div>
</div>

Example: Column Ordering

Easily change the order of our built-in grid columns with .push-md-* and .pull-md-* modifier classes.

.col-md-9 .push-md-3
.col-md-3 .pull-md-9
<div class="row">
  <div class="col-md-9 push-md-3">.col-md-9 .push-md-3</div>
  <div class="col-md-3 pull-md-9">.col-md-3 .pull-md-9</div>
</div>

Customizing the Grid

Using our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, the container widths, and the grid gutter widths—then recompile.

For example, if you wanted just three grid tiers, you’d update the $grid-breakpoints, $container-max-widths, and $grid-gutter-widths to something like this:

$grid-breakpoints: (
  sm: bp-to-em(480px),
  md: bp-to-em(768px),
  lg: bp-to-em(1024px)
);

$container-max-widths: (
  sm: rem-calc(420px),
  md: rem-calc(720px),
  lg: rem-calc(940px)
);

$grid-gutter-widths: (
    sm: 1.5rem,
    md: 2rem,
    lg: 2rem
);

Save your changes and recompile to have a brand new set of predefined grid classes for column widths, offsets, pushes, and pulls. Responsive visibility utilities will also be updated to use the custom breakpoints.

Sass Variables and Mixins

When using Figuration’s source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts.

Variables

Variables and maps determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.

Some Sass functions are in use here. Simply put bp-to-em() converts a pixel value to em assuming 16px root font size, while rem-calc() converts a pixel value to rem, but checks the defined $font-size-root variable in the Sass and uses that for conversion.

$grid-columns:      12;

$grid-breakpoints: (
  // Extra small screen / phone
  xs: 0,
  // Small screen / phone
  sm: bp-to-em(576px),
  // Medium screen / tablet
  md: bp-to-em(768px),
  // Large screen / desktop
  lg: bp-to-em(992px),
  // Extra large screen / wide desktop
  xl: bp-to-em(1200px)
);

$container-max-widths: (
  sm: rem-calc(544px),
  md: rem-calc(720px),
  lg: rem-calc(940px),
  xl: rem-calc(1140px)
);

$grid-gutter-width: 2rem;
$grid-gutter-widths: (
    xs: $grid-gutter-width,
    sm: $grid-gutter-width,
    md: $grid-gutter-width,
    lg: $grid-gutter-width,
    xl: $grid-gutter-width
);

Mixins

Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.

// Creates a wrapper for a series of columns
@mixin make-row($gutter: $grid-gutter-width) {
    @include clearfix();
    margin-left:  ($gutter / -2);
    margin-right: ($gutter / -2);
}

// Make the element grid-ready
@mixin make-col($size, $columns: $grid-columns, $gutter: $grid-gutter-width) {
    position: relative;
    min-height: 1px;
    padding-right: ($gutter / 2);
    padding-left:  ($gutter / 2);
    float: left;
    width: percentage($size / $columns);
}

// Get fancy by offsetting, or changing the sort order
@mixin make-col-offset($columns) {
  margin-left: percentage(($columns / $grid-columns));
}
@mixin make-col-push($columns) {
  left: percentage(($columns / $grid-columns));
}
@mixin make-col-pull($columns) {
  right: percentage(($columns / $grid-columns));
}

Example Usage

You can modify the variables to your own custom values, or just use the mixins with their default values. Here’s an example of using the default settings to create a two-column layout with a gap between.

See it in action in this rendered example.

.container {
  max-width: 60em;
  @include make-container();
}
.row {
  @include make-row();
}
.content-main {
  @media (max-width: 32em) {
    @include make-col(6);
  }
  @media (min-width: 32.1em) {
    @include make-col(8);
  }
}
.content-secondary {
  @media (max-width: 32em) {
    @include make-col(6);
  }
  @media (min-width: 32.1em) {
    @include make-col(4);
  }
}
<div class="container">
  <div class="row">
    <div class="content-main">...</div>
    <div class="content-secondary">...</div>
  </div>
</div>

Flexbox

Looking for a more modern grid system? Use the opt-in flexbox mode, or enable full flexbox support in Figuration, to take full advantage of CSS’s Flexible Box module for even more control over your site’s layout, alignment, and distribution of content.

Opt-in vs Full Mode

The opt-in mode for flexbox support is available by default, and is easily triggered by adding .row-flex to any .row containers. Any nested containers using just the .row class resets to the standard float grid layout.

Full mode needs to be enabled in the Sass and the CSS needs to be recompiled. In this mode, you do not need to use the .row-flex class, and all grid items will use display: flex; for layout.

What is Available

  • Nesting, offsets, pushes, pulls, and .no-gutters are all supported in the flexbox grid system.
  • Flexbox grid columns without a set width will automatically layout with equal widths. For example, four columns will each automatically be 25% wide.
  • Flexbox grid columns have significantly more alignment options available, including vertical alignment.

Auto-Layout Columns

When flexbox support is used/enabled, you can utilize breakpoint-specific column classes to control column widths.

Equal Width Columns

Equal-width columns are easliy done by adding any number of .col-{breakpoint}s for each breakpoint you need and every column will be the same width.

For example, here’s are some grid layouts that apply to every device and viewport possible.

1 of 2
1 of 2
1 of 3
1 of 3
1 of 3
Columns
with no
gutters
<div class="row row-flex">
    <div class="col">
        1 of 2
    </div>
    <div class="col">
        1 of 2
    </div>
</div>

<div class="row row-flex">
    <div class="col">
        1 of 3
    </div>
    <div class="col">
        1 of 3
    </div>
    <div class="col">
        1 of 3
    </div>
</div>

<div class="row row-flex no-gutters">
  <div class="col">Columns</div>
  <div class="col">with no</div>
  <div class="col">gutters</div>
</div>

Controlled Width Column

You can also set the width of one column and the others will automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths.

In the examples below, note that the other columns will resize no matter the width of the center column.

1 of 3
2 of 3 (col-6)
3 of 3
1 of 3
2 of 3 (col-5)
3 of 3
<div class="row row-flex">
    <div class="col">
        1 of 3
    </div>
    <div class="col-6">
        2 of 3 (col-6)
    </div>
    <div class="col">
        3 of 3
    </div>
</div>

<div class="row row-flex">
    <div class="col">
        1 of 3
    </div>
    <div class="col-5">
        2 of 3 (col-5)
    </div>
    <div class="col">
        3 of 3
    </div>
</div>

Variable Width Column

Using the col-{breakpoint}-auto classes, a column can size itself based on the natural width of its content. This can be handy when dealing with single line content like inputs, numbers, etc. This, in conjunction with horizontal alignment utility classes, is very useful for centering layouts with uneven column sizes as viewport width changes.

1 of 3
Variable width content
3 of 3
1 of 3
Variable width content
3 of 3
<div class="container">
    <div class="row row-flex flex-md-center">
        <div class="col col-lg-2">
            1 of 3
        </div>
        <div class="col-12 col-md-auto">
            Variable width content
        </div>
        <div class="col col-lg-2">
            3 of 3
        </div>
    </div>
    <div class="row row-flex">
        <div class="col">
            1 of 3
        </div>
        <div class="col-12 col-md-auto">
            Variable width content
        </div>
        <div class="col col-lg-2">
            3 of 3
        </div>
    </div>
</div>

Alignment

If you wish to have better control over your flexbox grid alignment, there are a handful of utility classes that might be helpful. Information and examples can be found in the Flexbox utilities page.