Without grids, designing and implementing responsive layouts would not be possible. There are many grid systems available, each with their pros and cons, but for WFP UI, we have picked a very versatile, powerful, and relatively easy to use grid system, designed by Yahoo team for Pure CSS framework.
Notice
Grids are totally optional. Please, refer to Getting Started section for information on including WFP UI + Grids in your projects.
Basics
Two types of classes
Grids in WFP UI make use of only two types of classes: the grid class (wfp-grid
) and unit classes (wfp-u
or wfp-u-*
) to form layouts.
Units are fractions
Units have various names that represent their widths; i.e.: wfp-u-1-2
, wfp-u-3-4
, and wfp-u-1-5
represent widths of 50% (1/2), 75% (3/4), and 20% (1/5), respectively. All widths are relative to the width of their grid container (wfp-grid
).
Child elements of a grid must be units
Child elements contained within an element with a wfp-grid
classname must be a grid unit with a wfp-u
or wfp-u-*
classname.
Content goes inside grid units
All content which is visible to people needs to be contained inside a grid unit. This ensures that the content will be rendered properly.
Grid units do not have gutters by default
To give you more control over your layouts, we have not applied default gutters to grid units. You can apply your own gutters via padding, for example by using wfp-box
classname.
Example
Thirds
Thirds
Thirds
Grid Units Sizes
Our grid allows you to use both a 5ths and 24ths based grid. Below you can find all the available units that can be appended to the wfp-u-*
classname, where *
is one the unit fractions, i.e.: to achieve a 50% width, use wfp-u-1-2
.
Notice
Grid containers (wfp-grid
) always expand to fill 100% width of their parent.
5ths-based units
24ths-based units
Media Queries
This grid system allows you to take control over grid behaviour at certain breakpoints by including additional class names. Use the following table to see what default breakpoints are supported.
Key | CSS Media Query | Breakpoint | Classname |
---|---|---|---|
sm |
@media screen and (min-width: 35.5em) |
≥ 568px | .wfp-u-sm-* |
md |
@media screen and (min-width: 48em) |
≥ 768px | .wfp-u-md-* |
lg |
@media screen and (min-width: 64em) |
≥ 1024px | .wfp-u-lg-* |
xl |
@media screen and (min-width: 80em) |
≥ 1280px | .wfp-u-xl-* |
Usage
The following code sample shows how to use grids to build a responsive layout for your pages using CSS Media Queries, as well as manage content layouts based on grids.
Notice
If you want to maintain appropriate padding on the edge of a multiple-column layout when using wfp-box
class, please make sure that your columns collapse only to a single-column layout, on screens smaller than the md
breakpoint.
Preview
Title
This is a sample paragraph, written to showcase how you can arrange your content. It's not very long and you didn't have to read it anyway.
Label #1
Label #2
Label #1
Label #2
Label #3
Source
Portions of this page have been sourced from purecss.io.