0% found this document useful (0 votes)
56 views4 pages

Simple Grid Layouts

The document describes several simple CSS grid patterns for projects, including an adjustable grid with modifier classes, a grid with auto-placed columns, a layout to push the footer down, and a stacking grid. Links to videos demonstrating the patterns are provided.

Uploaded by

Romany Refaat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

Simple Grid Layouts

The document describes several simple CSS grid patterns for projects, including an adjustable grid with modifier classes, a grid with auto-placed columns, a layout to push the footer down, and a stacking grid. Links to videos demonstrating the patterns are provided.

Uploaded by

Romany Refaat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

kevinpowell.

co

Simple Grid Patterns


for your projects

Adjustable grid
with modifiers
.grid {
.grid-3 { --column-count: 3; }

--column-count: 3;

.grid-4 { --column-count: 4; }

.grid-5 { --column-count: 5; }
display: grid;

grid-template-columns: 
 with custom properties


repeat(var(--column-count), 1fr);
.grid { --column-count: 1; }

}
@media (min-width: 600px) {

Set the desired column count using custom .grid { --column-count: 3; }

properties.
}

You can easily make several different grids @media (min-width: 960px) {

with modifier classes, or adjust the column .grid { --column-count: 4; }

count inside media queries. }

grid auto-columns This creates a grid


where the browser will
.auto-grid {
figure out how many
display: grid;
columns there will be.

grid-template-columns: 

repeat(auto-fit, minmax(min(200px, 100%), 1fr));
It does this based on
the the number of
}
children and the
amount of available
space that they have,
The 200px is the desired minimum size, the 100% based on the
prevents overflow if ever the parent is narrower minimum size you
than 200px.
have provided.
kevinpowell.co

Simple Grid Patterns


for your projects

Pushing the footer .main-layout {

down min-height: 100vh;

If you have short pages and want to display: grid;

ensure the footer always stays at grid-template-rows: 



the bottom, we can use this grid as rows 1fr rows;

the main layout.


}

The stack
If ever you need to layer
.the-stack {
elements on top of each
display: grid;
other, say an image or video
grid-template-areas: "stack";
as a background with some
text on top of it, this will do
place-items: center;
the trick, placing all elements
}

on top of one another as well


as vertically and horizontally
.the-stack > * {
centering everything.
grid-area: stack;

If you want to see them in action, the first two are looked at in this video

and the second two are looked at in this video .

If you’re still struggling with grid, I’d suggest checkout out this video that

looks at what I think are the easiest ways to get going with it.
kevinpowell.co

Simple Grid Patterns


for your projects

Adjustable grid
with modifiers
.grid {
.grid-3 { --column-count: 3; }

--column-count: 3;

.grid-4 { --column-count: 4; }

.grid-5 { --column-count: 5; }
display: grid;

grid-template-columns: 
 with custom properties


repeat(var(--column-count), 1fr);
.grid { --column-count: 1; }

}
@media (min-width: 600px) {

Set the desired column count using custom properties.


.grid { --column-count: 3; }

You can easily make several different grids with


modifier classes, or adjust the column count inside
media queries. @media (min-width: 960px) {

.grid { --column-count: 4; }

grid auto-columns This creates a grid where


the browser will figure out
.auto-grid {
how many columns there
will be.

display: grid;

grid-template-columns: 
 It does this based on the


repeat(auto-fit, minmax(min(200px, 100%), 1fr));
the number of children and
the amount of available
} space that they have,
based on the minimum size
you have provided.
The 200px is the desired minimum size, the 100%
prevents overflow if ever the parent is narrower
than 200px.
kevinpowell.co
Simple Grid Patterns
for your projects
Pushing the footer .main-layout {

down min-height: 100vh;

If you have short pages and want to ensure


the footer always stays at the bottom, we
display: grid;

can use this grid as the main layout. grid-template-rows: 



rows 1fr rows;

The stack If ever you need to layer elements


.the-stack {
on top of each other, say an image
or video as a background with
display: grid;
some text on top of it, this will do
grid-template-areas: "stack";
the trick, placing all elements on
top of one another as well as
place-items: center;
vertically and horizontally centering
}

everything.

.the-stack > * {

grid-area: stack;

If you want to see them in action, the first two are looked at in this video

https://youtu.be/r1IitKbJRFE

The second two are looked at in this video 



https://youtu.be/JHregeIsjPQ

If you’re still struggling with grid, I’d suggest checkout out this video that

looks at what I think are the easiest ways to get going with it

( https://youtu.be/rg7Fvvl3taU )

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy