Fireship · @fireship
CSS Grid in 100 Seconds
Uploaded March 5, 2020 · Length 1:51
Summary
learn css grid layout in 100 seconds, including grid template areas, tracks, and gap property.
- css grid
- css layout
- grid template areas
- css grid tutorial
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
CSS grin a system for laying out items
- 0:02
across a movable set of horizontal and
- 0:05
vertical lines inside a grid we have
- 0:07
invisible lines that divide columns and
- 0:09
rows the space between two parallel grid
- 0:11
lines is known as a grid track and the
- 0:13
space between four lines is known as a
- 0:15
grid area in your HTML start with a
- 0:17
parent element to serve as your grid
- 0:19
container then all of its children will
- 0:21
automatically become grid items let's
- 0:23
imagine we wanted to build a website
- 0:24
with a holy grail layout in the HTML if
- 0:27
we have a container with five elements
- 0:29
inside we'll start by setting the
- 0:30
containers display property to grid now
- 0:32
open your app in Firefox to visualize
- 0:34
the gridlines tracks and areas it helps
- 0:37
to imagine your website as an Excel
- 0:38
spreadsheet in each individual cell add
- 0:40
a label that represents the element that
- 0:42
should appear there each cell in the
- 0:44
grid represents one fractional unit in
- 0:46
the middle we have an advertisement the
- 0:48
main content and the sidebar then we
- 0:50
have the top bar taking up three cells
- 0:51
on the top and a footer on the bottom
- 0:53
notice how this represents a three by
- 0:55
three grid and we can use this as the
- 0:57
value for the grid template areas
- 0:58
property now we need to tell the
- 1:00
children which grid area that they take
- 1:02
up we can do that by providing the name
- 1:04
to the grid area property that gives us
- 1:06
the right layout but now we want to
- 1:07
adjust the size of the rows and columns
- 1:09
currently each column is taking up one
- 1:11
third or one fractional unit of the
- 1:13
available space we can change the width
- 1:15
of the middle column by setting it to a
- 1:17
fixed pixel value or change the ratio by
- 1:19
giving it three fractional units
- 1:20
likewise we can change the height of
- 1:23
rows using the grid template rows
- 1:24
property if we want to add spacing
- 1:26
between our grid lines we can use the
- 1:28
great gap property and we can Center the
- 1:30
children vertically or horizontally
- 1:31
using justify items or line items and
- 1:34
make sure to check out the min Max and
- 1:36
repeat functions to avoid duplication on
- 1:38
larger grids this has been CSS grid and
- 1:40
100 seconds stay tuned for a full grid
- 1:42
project in a few days and make sure to
- 1:44
hit the like button if you want to see
- 1:46
more short videos like this thanks for
- 1:48
watching and I will see you in the next
- 1:49
one


