Foundation grid instance


May 04, 2021 14:00 Foundation5


Table of contents


Foundation grid instance

Below we've collected some common examples of grids.


Three equal columns

This example shows how to create three equal columns (33.3%/33.3%/33.3%), display three columns on medium and large devices, and automatically stack them on small devices:

Instance

< 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 out . . .

Three unethiest columns

This example shows how to create three unealable columns (25%/50%/25%), display three columns on medium and large devices, and automatically stack them on small devices:

Instance

< 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 out . . .

Two equal columns

This example shows how to create two equal columns (50%/50%), which are always 50%/50% on small, medium, and large devices:

Instance

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

Try it out . . .

Two columns of uneth liketh

This example shows how to create two unethiesty columns (33.3%/66.6%), with a consistent ratio of 33.3%/66.6% on small, medium and large devices:

Instance

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

Try it out . . .

Modify the order of the columns

Modify the order | columns | using the .small|medium|large-pull-* .small|medium|large-push-*

Instance

< 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 out . . .

Nested columns

You can use nested grids (columns inserted in columns):

Instance

< 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 out . . .

Mix: Mobile, desktop

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

Tip: Each class can be zoomed in, and if you want small and large screen devices to be the same width, you can .small-*

Instance

< 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 out . . .

混合:手机、平板和桌面设备

Instance

< 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 out . . .

The center column

The .small-centered the column. Medium and large devices can inherit the center of small devices, but you need to set up a center class .large-centered

Instance

< 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 out . . .

列偏移量

可以使用 .large-offset-* (或 .small-offset-* ) 类设置列向右移。 左侧外边距的列数量使用 * 号控制:

Instance

< 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 out . . .

Incomplete column

If the number of columns in a row does not add up to 12, Foundation automatically floats the last column to the right and fills the remaining columns with white space.

Optional The .end is used to set the elements of the last column to float to the left:

Instance

< 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 out . . .

Widescreen

The maximum .row mesh (.row) (max-width) is 62.5rem. T he size on a widescreen device may be larger than 62.5rem, so that the column does not fill the page completely, even if the width is set to 100%. But we can set up the new max-width through CSS:

Instance

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

Try it out . . .

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

Instance

< div style= "background-color:coral; p adding: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 out . . .