Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Foundation Grid System

Foundation Grid System

The Foundation grid system has 12 columns.

If you don't need 12 columns, you can combine some columns to create wider columns.

The Foundation grid system is responsive. Columns automatically resize based on screen size. On large screens there may be three columns, while on small screens there may be three single columns arranged in order.


Grid Columns

The Foundation grid system has three columns:

The above classes can be combined to create more flexible layouts


Basic Grid Structure

The following is a basic Foundation grid structure example:

Example

<

div

class=

"row"

<

div

class=

"small|medium|large-num columns"

<

/div

<

/div

<

div

class=

"row"

<

div

class=

"small|medium|large-num columns"

<

/div

<

div

class=

"small|medium|large-num columns"

<

/div

<

div

class=

"small|medium|large-num columns"

<

/div

<

/div

<

div

class=

"row"

  ...

<

/div

First, create a row (

). This is a horizontal vertical column. Then add the column count specification small-num, medium-num and large-num class. Note: the number of columns num must add up to 12:

Example

<

div

class=

"row"

<

div

class=

"small-12 columns"

.small-12 yellow

<

/div

<

/div

<

div

class=

"row"

<

div

class=

"small-8 columns"

.small-8 beige

<

/div

<

div

class=

"small-4 columns"

.small-4 gray

<

/div

<

/div

<

div

class=

"row"

<

div

class=

"large-9 small-8 columns"

.small-8 .large-9 pink

<

/div

<

div

class=

"large-3 small-4 columns"

.small-4 .large-3 orange

<

/div

<

/div

Try it »

In the example, the first row's

class is .small-12, which creates 12 columns (100% width).

The second row creates two columns, .small-4 has a width of 33.3%,.small-8 has a width of 66.6%.

In the third row we added two extra columns (.large-3 and .large-9). This means that on large screen sizes, the columns become 25% (.large-3) and 75% (.large-9) ratio. At the same time we also specified the column ratio on small screens as 33% (.small-4) and 66% (.small-8). This combination is very helpful for display effects on different screens.

Grid Options

The following table summarizes the Foundation grid system across multiple devices:

| | Small devices
Phones (<40.0625em (640px)) | Medium devices
Tablets (>=40.0625em (640px)) | Large devices
Laptops & Desktops (>=64.0625em (1025px)) | | --- | --- | --- | --- | | Grid behavior | Always horizontal | Starts collapsed, horizontal above the breakpoint | Starts collapsed, horizontal above the breakpoint | | Class Prefix | .small-* | .medium-* | .large-* | | Number of Classes | 12 | 12 | 12 | | Nesting Allowed | Yes | Yes | Yes | | Offsets | Yes | Yes | Yes | | Column ordering | Yes | Yes | Yes |


Wide Screens

Maximum grid (.row) width is 62.5rem. On widescreen, when the width is greater than 62.5rem, columns will not span the page width even if the width is set to 100%. But you can reset max-width via CSS:

Example

<

style

.row {

    max-width: 100%;

}

<

/style

Try it »

If you use the default max-width, but want the background color to span the entire page width, you can use .row to wrap the entire container and specify the background color you need:

Example

 

   

.small-6

   

.small-6

 

Try it »