Gridz Utility Classes
The aim with these classes is to be able to layout almost anything with CSS grid that uses grid boxes of the same width value. This is primarily designed to be used inside of the legacy grid at either mobile, 700px or 940px.†
These grid classes have built in fallbacks for browsers who do not have grid support, in most cases, this falls back to using flexbox to give a similar experience.
† Note: While these classes may be helpful for some uses, you may want to consider using the grid-column classes which has more flexibility and better handles larger, full-bleed
containers.
Container
To setup a set of gridz boxes, you will need a containing element. This is usually a div as this container has no real semantic value. There are two required classes that need to be set on this container, one to setup the grid container gridz
and one to determine how many grid boxes will be in each row (gridz-2
, gridz-3
or gridz-4
).
example
The sizing for this container is based on the width of the content section on a typical page on the Tyndale website at the largest screen size — 700px. These boxes will then reduce in size and/or wrap to a new line depending on the available screen space.
Default Gridz Settings
By default, grid boxes contained in a gridz
container will have the following defaults:
Overriding Default Gridz Settings
The default settings of the gridz container and grid boxes contained inside of it can be overridden either at the container level or on individual box†
gridz-gap-$†
The gridz-gap-$
class will determine the amount of space between the grid boxes on all sides. This class should be placed on the container element. The default grid-gap
is 20px — here are the override options:
gridz-gap-0
gridz-gap-5
gridz-gap-10
gridz-gap-15
† the gridz-gap-$
class can only be set on the container, not on individual gridz-boxes
gridz-border
Adding this class will add a simple border to either all boxes (container) or an individual box (element) that is the appropriate color for the grid box — this is based on the box’s background color.
gridz-padding-$
The gridz-padding-$
class will determine the amount of padding in each of the grid boxes. This can be added at the container level or at each individual gridz-box
. The default grid-padding
value is 20px — here are the override options:
gridz-padding-0
gridz-padding-5
gridz-padding-10
gridz-padding-15
gridz-padding-20
‡gridz-padding-40
Note: the regular padding classes can be used as well for individual boxes.
‡ the value of 20 is available in case the container value is set at some other value and you would like to override one individual box in that set with the value of 20.
gridz-bg-$ (background color)
The gridz-bg-$
class will determine the color of the background in each of the grid boxes. The default grid-bg value is none (white) — here are the override options:
gridz-bg-light
— the $light variable value (#efefef), color: $dark (#222)gridz-bg-dark
— the $dark variable value (#222), color: $white (#fff)gridz-bg-blue
— linear-gradient(to right, #221155 0%,#1e1c8e 100%), color: $white (#fff)gridz-bg-red
— linear-gradient(to right, #b22 0%,#e22 100%), color: $white (#fff)
Note: link and heading colors have been adjusted for each background option.
Adding Grid boxes
Once you have your container setup you can start adding individual boxes to the container. Each of these grid boxes need to be contained inside a div using the class of gridz-box.
example
Example Usage
You can use a combination of classes to produce a number of different layouts — here are some examples. Note — these examples are using a special class (contained-700
) to keep the same dimensions as the content section on the Tyndale website with a sidebar. The box-shadow area represents the page.
Grid 2 Columns with default settings
Grid Box Title
This is some example text with a link to nowhere in it. Some boxes have more copy than others...
Grid Box Title
This is some example text with a link to nowhere in it.
Grid Box Title
This is some example text with a link to nowhere in it.
Grid Box Title
This is some example text with a link to nowhere in it. Some boxes have more copy than others...
Grid 2 Columns with gap, background, border and padding overrides
Grid Box Title
This is some example text with a link to nowhere in it. Some boxes have more copy than others...
Grid Box Title
This is some example text with a link to nowhere in it.
Grid Box Title
This is some example text with a link to nowhere in it.
Grid Box Title
This is some example text with a link to nowhere in it. Some boxes have more copy than others...
Grid 3 Columns with border and gap override as well as single box color override
This is some example text with a link to nowhere in it.
Why don't you check it out!
Grid Box Title
This is some example text with a link to nowhere in it. This box also has more text than the others one do.
Grid 2 Columns with border, image and padding override with inner padding
Grid Box Title
This is some example text with a link to nowhere in it. This box also has more text than the others one do.
Note: this example introduces a new class that can be added to an internal div to add additional padding to just that div — gridz-inner. In this case, the containing gridz-box has no padding so that the image displays the full width, but we do want padding on the content section below it.
Grid 4 Columns with border and some box color overrides
If you would like to play with some ideas, you could checkout this Codepen and play around. This may be in disarray as it is used as a playground for myself as well…