zurb/foundation
Foundation is a responsive front-end framework for building sites and apps on any device. Includes a customizable grid, Sass mixins, JavaScript plugins, and accessibility support, with docs and releases available to help you go from prototype to production.
title: The Grid description: Create powerful multi-device layouts quickly and easily with the default 12-column, nestable Foundation grid. If you're familiar with grid systems, you'll feel right at home. If not, you'll learn quickly. video: k1zizfK2xbQ sass:
To use the Float Grid in Foundation v6.4+, you need to:
foundation-float.css in place of foundation.css.$xy-grid and $global-flexbox to false.Start by adding an element with a class of .row. This will create a horizontal block to contain vertical columns. Then add elements with a .column class within that row. Specify the widths of each column with the .small-#, .medium-#, and .large-# classes.
Foundation is mobile-first. Code for small screens first, and larger devices will inherit those styles. Customize for larger screens as necessary.
<div class="row">
<div class="columns small-2 large-4"><!-- ... --></div>
<div class="columns small-4 large-4"><!-- ... --></div>
<div class="columns small-6 large-4"><!-- ... --></div>
</div>
<div class="row">
<div class="columns large-3"><!-- ... --></div>
<div class="columns large-6"><!-- ... --></div>
<div class="columns large-3"><!-- ... --></div>
</div>
<div class="row">
<div class="columns small-6 large-2"><!-- ... --></div>
<div class="columns small-6 large-8"><!-- ... --></div>
<div class="columns small-12 large-2"><!-- ... --></div>
</div>
<div class="row">
<div class="columns small-3"><!-- ... --></div>
<div class="columns small-9"><!-- ... --></div>
</div>
<div class="row">
<div class="columns large-4"><!-- ... --></div>
<div class="columns large-8"><!-- ... --></div>
</div>
<div class="row">
<div class="columns small-6 large-5"><!-- ... --></div>
<div class="columns small-6 large-7"><!-- ... --></div>
</div>
<div class="row">
<div class="columns large-6"><!-- ... --></div>
<div class="columns large-6"><!-- ... --></div>
</div>
Small grids expand to large screens easier than large grids cram into small screens.
<div class="row">
<div class="columns small-2">2</div>
<div class="columns small-10">10</div>
</div>
<div class="row">
<div class="columns small-3">3</div>
<div class="columns small-9">9</div>
</div>
Medium sized screens will inherit styles from small, unless you specify a different layout using the medium grid classes.
<div class="row">
<div class="columns medium-2">2</div>
<div class="columns medium-10">10</div>
</div>
<div class="row">
<div class="columns medium-3">3</div>
<div class="columns medium-9">9</div>
</div>
If you have just a single column, you can save some markup by combining the .row and .column classes together on the same element. You can still nest more grids inside this container like usual.
<div class="column row">
Row column
</div>
Normally, a row is always 1200 pixels wide. Make a row completely fluid by adding the .expanded class.
<div class="expanded row">
</div>
You can nest the grids indefinitely, though at a certain point it will get absurd.
<div class="row">
<div class="columns small-8">8
<div class="row">
<div class="columns small-8">8 Nested
<div class="row">
<div class="columns small-8">8 Nested Again</div>
<div class="columns small-4">4</div>
</div>
</div>
<div class="columns small-4">4</div>
</div>
</div>
<div class="columns small-4">4</div>
</div>
Move blocks up to 11 columns to the right by using classes like .large-offset-1 and .small-offset-3.
<div class="row">
<div class="columns large-1">1</div>
<div class="columns large-11">11</div>
</div>
<div class="row">
<div class="columns large-1">1</div>
<div class="columns large-10 large-offset-1">10, offset 1</div>
</div>
<div class="row">
<div class="columns large-1">1</div>
<div class="columns large-9 large-offset-2">9, offset 2</div>
</div>
<div class="row">
<div class="columns large-1">1</div>
<div class="columns large-8 large-offset-3">8, offset 3</div>
</div>
In order to work around browsers' different rounding behaviors, Foundation will float the last column in a row to the right so the edge aligns. If your row doesn't have a count that adds up to 12 columns, you can tag the last column with a class of .end in order to override that behavior. Alternatively, you can set the $grid-column-align-edge variable to false to turn off this behavior entirely.
<div class="row">
<div class="columns medium-3">3</div>
<div class="columns medium-3">3</div>
<div class="columns medium-3">3</div>
</div>
<div class="row">
<div class="columns medium-3">3</div>
<div class="columns medium-3">3</div>
<div class="columns medium-3 end">3 end</div>
</div>
The grid gutter—the space between two columns in a row, and the space between the edge of a grid and the edge of the page—is responsive, and becomes larger on larger screens.
| Breakpoint | Gutter Size |
|---|---|
small |
20px |
medium |
30px |
If you're using the Sass version of Foundation, you can change these defaults by editing the $grid-column-gutter variable map:
$grid-column-gutter: (
small: 20px,
medium: 30px,
);
To add more gutter definitions, add new lines to the map. The breakpoint names used here must match a breakpoint name in your project's $breakpoints map.
If you prefer using one gutter size for every breakpoint, just use a single number for the $grid-column-gutter variable:
$grid-column-gutter: 30px;
You can also explicitly set the gutter size for a particular grid row by adding the .gutter-[size] class. This is useful when your using responsive gutters but specific components need static gutters.
<div class="row gutter-small">
<div class="columns">This grid always has small gutters</div>
</div>
The .collapse class lets you remove column gutters (padding).
There are times when you won't want each media query to be collapsed or uncollapsed. In this case, use the media query size you want and collapse or uncollapse and add that to your row element. Example shows gutters at small and medium and no gutters on large and up.
<div class="row medium-uncollapse large-collapse">
<div class="columns small-6">
Removes gutter at large media query
</div>
<div class="columns small-6">
Removes gutter at large media query
</div>
</div>
Center your columns by adding a class of .small-centered to your column. Large will inherit small centering by default, but you can also center solely on large by applying a .large-centered class. To uncenter on large screens, use .large-uncentered.
<div class="row">
<div class="columns small-3 small-centered">3 centered</div>
</div>
<div class="row">
<div class="columns small-6 large-centered">6 centered</div>
</div>
<div class="row">
<div class="columns small-9 small-centered large-uncentered">9 centered</div>
</div>
<div class="row">
<div class="columns small-11 small-centered">11 centered</div>
</div>
Using these source ordering classes, you can shift columns around between our breakpoints. This means if you place sub-navigation below main content on small displays, you have the option to position the sub-navigation on either the left or right of the page for large displays. Prefix push/pull with the size of the device you want to apply the styles to. .medium-push-#, .large-push-# is the syntax you'll use. Use the number 0 instead to reset a push/pull, such as .medium-push-0 or .large-pull-0.
<div class="row">
<div class="columns small-10 small-push-2">10</div>
<div class="columns small-2 small-pull-10">2, last</div>
</div>
<div class="row">
<div class="columns large-9 large-push-3">9</div>
<div class="columns large-3 large-pull-9">3, last</div>
</div>
<div class="row">
<div class="columns large-8 large-push-4">8</div>
<div class="columns large-4 large-pull-8">4, last</div>
</div>
<div class="row">
<div class="columns small-5 small-push-7 medium-7 medium-push-5">7</div>
<div class="columns small-7 small-pull-5 medium-5 medium-pull-7">5, last</div>
</div>
<div class="row">
<div class="columns medium-6 medium-push-6">6</div>
<div class="columns medium-6 medium-pull-6">6, last</div>
</div>
Block grids are a shorthand way to create equally-sized columns. Add a class of the format .[size]-up-[n] to change the number of columns within the row. By default, the max number of columns you can use with block grid are 8. Adding the .column-block class to columns will apply a bottom margin equal to the width of gutters.
<div class="row small-up-2 medium-up-3 large-up-4">
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
<div class="column column-block">
<img src="https://placehold.it/600x600" class="thumbnail" alt="">
</div>
</div>
---...
How can I help you explore Laravel packages today?