Grid Columns Documentation
Step 1: Add grid-columns container
To setup a set of grid-column, you will need to declare a containing element. You do this by adding the class grid-columns
.
Default grid-columns settings
- Column gap: 0
- Row gap: 0
- Padding: 0
- Border: 0
Step 2: Specify number of columns for all screen sizes or for specific breakpoints
Options and their class:
- 2 columns:
grid-columns--2
- 3 columns:
grid-columns--3
- 4 columns:
grid-columns--4
- 5 columns:
grid-columns--5
Responsive breakpoints:
- sm: 550px;
- md: 768px;
- lg: 900px;
- xl: 1280px;
Options for specific breakpoints
- 2 columns:
grid-columns--2@[sm|md|lg|xl]
- 3 columns:
grid-columns--3@[sm|md|lg|xl]
- 4 columns:
grid-columns--4@[sm|md|lg|xl]
- 5 columns:
grid-columns--5@[sm|md|lg|xl]
Step 3: Add grid column
Step 4: Specify number of columns a column should span (optional)
You can span one grid section over multiple columns to make layouts such as [2/3 / 1/3] -or- [1/5 / 3/5 / 1/5] -or- [1/3 / 2/3]
Step 5: Use utility classes to style (optional)
Grid column gap
.column-gap-0
.column-gap-px
.column-gap-sm
.column-gap-md
.column-gap-lg
.column-gap-xl
.column-gap-2xl
.column-gap-3xl
.column-gap-4xl
Grid row gap
.row-gap-0
.row-gap-px
.row-gap-sm
.row-gap-md
.row-gap-lg
.row-gap-xl
.row-gap-2xl
.row-gap-3xl
.row-gap-4xl
Adding Padding & Margin
These classes are not specific to the grid-column system, but work well in creating the right layout when using the grid-column system. (CSS box model docs)
Padding
Padding can be added [inside] any container on all sides using p-xl
or on individual sides using pt-xl
pr-xl
pb-xl
pl-xl
(top, right, bottom, left). The values (ex. -xl) can be mixed as needed.
.p[t|r|b|l]-0
.p[t|r|b|l]-px
.p[t|r|b|l]-sm
.p[t|r|b|l]-md
.p[t|r|b|l]-lg
.p[t|r|b|l]-xl
.p[t|r|b|l]-2xl
.p[t|r|b|l]-3xl
.p[t|r|b|l]-4xl
Margin
Margin can be added [outside] any container on all sides using m-xl
or on individual sides using mt-xl
mr-xl
mb-xl
ml-xl
(top, right, bottom, left). The values (ex. -xl) can be mixed as needed
.m[t|r|b|l]-0
.m[t|r|b|l]-px
.m[t|r|b|l]-sm
.m[t|r|b|l]-md
.m[t|r|b|l]-lg
.m[t|r|b|l]-xl
.m[t|r|b|l]-2xl
.m[t|r|b|l]-3xl
.m[t|r|b|l]-4xl
Pulling it all together
Here is an example of a number of the classes put together to create a 2/3 / 1/3 layout that spans the full page — additional helper classes will be explained below…
full-bleed
- this will make thisdiv
span the full width of the page. This can not be used if there is a menu on the page. Background color can also be added to these full bleed sections using the Background colour classes.wrapper
- this class will add appropriate padding (4rem) on the left and right so the content will be spaced away from the edge of the browser window
This example was taken from https://www.tyndale.ca/alumni in the “Alumni Benefits / Support Tyndale Students” section of the page.