0:02 right can you guys see my
0:05 screen I can't see you guys so hold
0:09 on all right can I get a thumbs up so
0:12 we'll go ahead and um let's um let's
0:17 download today's today's lab so we gets
0:21 all set up so if you go into courses
0:25 modules and we are on module seven wow
0:28 already and you go to lab and S
0:34 beginning let's go ahead and download
0:36 the zip
0:46 file
0:48 okay and I'm going to put my zip file
0:52 into my
0:54 desktop and then I'm going to start a
0:57 visual studio code
1:04 so here I have Visual Studio code I'm
1:07 going to go to file open
1:10 folder and uh desktop I have it on my
1:13 desktop so have my lab beginning and go
1:16 ahead and open and so I have this all
1:20 set up so can I get a thumbs up when you
1:22 guys are all set up and ready to go
1:34 see
1:37 one
1:43 two couple
1:46 more all right
1:54 great okay all right so today we are
1:57 going to learn about uh
2:01 the CSS grid layout this is different
2:05 from the grid when we talk about design
2:08 and stuff this is the actual CSS grid
2:10 display grid um this is our agenda for
2:13 today uh we're going to learn the grid
2:16 terminology uh grid containers and grid
2:19 items and then we're start creating our
2:21 first CSS grid and then we're going to
2:23 go through a couple different uh the
2:25 grid properties to discuss you know how
2:28 to work in the grid
2:30 and stuff so um if you guys liked Flex
2:34 box Flex box as you might remember is
2:37 more onedimensional right so in Flex box
2:40 we either had the flex direction of row
2:42 or Flex direction of column um but in
2:47 the
2:49 grid uh the grid is a two-dimensional
2:52 layout so now we got to be able to do
2:55 both um we do both columns and we do
2:59 rows so CSS always had to has been used
3:03 to lay out web pages but it's always
3:06 been not really good at it as you know
3:09 we learned using floats and stuff um at
3:12 first table were used uh so you see
3:14 those really old school um but you know
3:16 table's not responsive um and it was
3:19 very limited and then we used floats
3:22 like what we did in this class floats
3:25 with the you know absolute positioning
3:27 relative positioning um and also inline
3:30 block block um all of these methods
3:32 they're kind of like hacks in a way um
3:35 and it left out a lot of important
3:36 functionality so grid is the first CSS
3:39 module created specifically to solve a
3:41 lot of the layout problems um developers
3:44 have been hacking their way around for
3:46 years so the Grid it's a two-dimensional
3:49 grid based layout system that aims to do
3:51 nothing less than completely change the
3:53 way we design grid based user interfaces
3:56 is two-dimensional which means in the
3:58 grid itself we can handle both the
3:59 columns and the rows um kind of like a
4:03 HTML table uh but you'll find it way
4:06 more flexible than a HTML table um you
4:09 work with grid layout by applying CSS
4:11 rules to both a parent element which
4:13 becomes the grid container and to the
4:15 element's children which become grid
4:17 items so kind of like how we talked
4:19 about Flex right when we um set a
4:22 container to
4:24 flex um then that container you know
4:28 becomes the flex f parent Flex container
4:32 and then you have the flex items this
4:34 the same thing for grid we have a grid
4:36 container which becomes the grid items
4:38 so let's do some basic
4:40 terminology so when we set the parent
4:43 container to Grid or inline grid um the
4:47 that becomes uh the grid container so as
4:50 you can see here with the yellow line we
4:52 have the grid
4:54 container um the direct Children of the
4:58 grid container
5:00 um it's called grid
5:06 items uh the horizontal lines that
5:09 divide the grid and separate the columns
5:11 and rows are um are are called grid
5:15 lines um so you have your horizontal
5:18 lines and then you have your vertical
5:19 lines and just not this this is a 3X two
5:23 grid however with the lines it has one
5:26 more um than the actual number of column
5:29 rows and this is how you would number
5:31 them so this is position one starting on
5:35 the left hand side then two then three
5:38 then four for three col uh three column
5:42 grid uh for the two row grid then you
5:45 have starting from top to bottom and
5:48 that is a typo right there that should
5:50 be three let me change
5:55 it okay so you have the and then going
5:59 from Top top to bottom put uh one two
6:02 and three and you'll see why numbering
6:04 these like this are important later on
6:07 but just understand that you know this
6:09 is called grid
6:12 lines we have a grid track is a space
6:15 between two grid lines forming either a
6:17 grid row this is a horizontal track or
6:20 grid columns this is a vertical track so
6:23 for instance there's three grid columns
6:25 here and there's two grid rows
6:28 here pretty simple uh grid cell it's a
6:32 single unit in the grid where a grid
6:34 item can be placed so these are grid
6:37 items and this is a grid
6:39 cell kind of like if you think like a
6:41 table
6:43 cell uh grid Gap grid Gap is the gap in
6:46 between so just like Flex we have gaps
6:49 and grid as well so we have the gap
6:51 which is the shorthand for grow and
6:53 columns um and then we have the row Gap
6:56 and then the column Gap you can separate
6:58 them as
7:01 well uh and a grid area so a grid area
7:05 just means uh the multiple sections of a
7:08 grid so if I chose um so for instance
7:12 here these four make up a the grid area
7:15 and you could Define it using grid area
7:18 um
7:20 specifically and we'll talk about a
7:22 little bit later how this works but that
7:24 is just a basic
7:26 terminology um and that's it uh these
7:29 are all of the properties that we can
7:32 use and we're going to go through um I
7:35 believe every single one of these um
7:37 later as we go through this lecture but
7:39 this is just an overview so these are
7:41 the properties for the grid
7:45 container and these are the properties
7:47 for the grid item we're going to go
7:49 through all of these as
7:53 well so the container a grid container
7:57 is set by the clearing GD or display
8:01 inline grid and can use display sub grid
8:05 on the container element so um we're
8:08 going to use an
8:10 example um to create a grid and you can
8:14 see in the what it's going to happen is
8:18 uh we will create a grid and then the
8:21 items inside the grid will become grid
8:22 items uh the contents comprise a grid
8:25 with grid lines forming boundaries
8:27 around each grid area uh please note
8:30 that when we do create a grid these
8:32 won't work on anything in the grid
8:34 container float clear or vertical line
8:38 uh and margins won't collapse inside a
8:40 grid
8:42 container just like
8:47 Flex all right let
8:49 me
8:53 see okay so um before we do this let's
8:57 start by um braing our grid so if we can
9:00 pull
9:01 up um the visual studio code so what I'm
9:06 going to do this time is when I um show
9:10 you preview I'm going to take this and
9:13 I'm going to copy it and put it
9:16 into um um Chrome the reason I'm going
9:19 to do that today is
9:22 um is because I want to show you guys uh
9:25 inspect
9:26 element and what happens when we do in
9:29 ECT the elements I'm going to pull this
9:31 into to the
9:36 side just like the side by
9:43 side
9:45 okay all right
9:47 so you can see here um in this first
9:51 index we have a container a general
9:54 container and there's four items in my
9:56 container this container has a class of
9:59 C1 and I'm going to use Grid in here so
10:03 if you open the if you double click this
10:06 to stick the index Tab and I'm going to
10:10 open
10:11 Styles so the first thing I'm going to
10:13 do is Target
10:15 this do
10:19 C1 and I'm going to display
10:25 grid okay um and you can see right off
10:29 the B
10:30 um there's no change in here okay I'm
10:33 going to pull this out but if I right
10:36 click in Chrome and go to inspect this
10:39 is my inspect elements and close this so
10:42 you have a little bit and I go into here
10:44 where it says
10:47 layout right under grid um I'm going to
10:51 toggle the grid
10:54 overlay right so here you can see that
11:00 this is now grid
11:01 container right so if I take
11:05 this and I take it off you can see that
11:08 there's no grid right but the moment I
11:11 set this
11:13 grid okay suddenly it has it shows I
11:16 have a grid right it shows my uh grid
11:19 lines right here's a one two three four
11:24 five five grid
11:25 lines um and then one two grid lights so
11:30 you could see it automatically uh this
11:33 container has now become a
11:43 grid all right so I want to show you
11:45 guys also um we're going to uncomment
11:50 this one
11:51 now so you can see here that when I have
11:55 this grid overlay you can see that this
11:56 one's a grid and this one's not a grid
11:59 right
12:02 and I'm going to go ahead and in this
12:05 item I'm going to add a
12:08 margin 10
12:10 PX and this is to show you guys that
12:13 when you're in a regular block display
12:16 the margin collapses right so you can
12:19 see here that there's 10 PX on around
12:22 each one of these but since these two
12:24 both have margins they collapse within
12:26 each other however inside a grid key
12:29 here as you can see your margin doesn't
12:32 collapse so just understand margin does
12:34 not collapse when you're using
12:41 grid I'm going to go back to the
12:44 lecture
12:48 um so how a grid works is that we need
12:52 to define the rows and the columns so
12:55 there's several ways to Define rows and
12:57 columns so for our first grid we're
13:00 going to use the grid template columns
13:03 and grid template rows to to uh Define
13:07 the size of the rows and the columns for
13:09 our grid so these are all different
13:11 examples of how we can use grid template
13:14 columns um we're going to start off with
13:16 something really simple but for here um
13:19 you could oops let me go back here you
13:22 can see that um we're creating a 3X3
13:24 grid um and we are telling it to be 10
13:27 pixel 10 pixel 10 pixel for the column
13:30 um and 10 by uh 10 pixel 10 pixel 10
13:33 pixels for the rows um and then we're
13:36 going to go through each of these but
13:37 these are some other examples where we
13:39 could use a repeat function um here and
13:43 here and it just in this slide it just
13:45 shows you that we could use pixels we
13:48 could use a
13:50 percentages and we can use you know text
13:53 like
13:55 Auto all right so what we're going to do
13:58 is um let's go back
14:02 to here we go side by side and I'm going
14:07 to take my grid here and I'm going to
14:10 add uh I'm going to create a 2 by two
14:14 grid so I'm going to go ahead and uh do
14:17 grid template
14:19 columns and I want the First Column to
14:21 two be 200 pixels so see it only made
14:25 one column here right but if I want two
14:28 columns I just to space and I could tell
14:31 it to
14:33 um do a second column here 200 by
14:38 300 right and if I want to um change the
14:43 size of the rows I do temp grid template
14:47 rows uh I'm just going to do 120 for the
14:50 top one and 200 for the bottom so you
14:54 can see right here I created um my 2 by
14:58 two
15:00 grid and I to it that I want the columns
15:03 to be the first column to be 200 the
15:05 second column to be 300 I did the same
15:08 thing with the rows I want the rows the
15:10 top one to be 120 and then the bottom
15:12 one to be 200 it's pretty
15:17 cool right ahead and save
15:26 that all right so with um any questions
15:31 so that's pretty simple I think uh just
15:33 creating the grid container in the
15:36 grid we lost you guys so if anyone don't
15:39 say something put in the chat for some
15:43 reason I I did what you did right now
15:45 and uh it looks like the boxes are all
15:47 together there's no space
15:52 between so let's take a look um okay
15:56 oops there's no space between
15:59 yeah is it
16:01 because did you lose the margin oh yeah
16:05 I missed that I added a margin 10 but
16:08 you can remove it and we could just you
16:10 could take a look that's what happens
16:13 when you remove the
16:20 margin all right so with grid comes
16:25 something called the FR FR unit and this
16:26 is really really cool in a way um FR
16:29 unit stands for fraction units so it
16:32 basically tells you um basically um it's
16:36 input that automatically calculates the
16:38 layout divisions while adjusting for
16:40 gaps inside the grid so you can see that
16:43 what we did before we actually tow the
16:44 grid you know 200 pixel to 500 and 500
16:48 pixel but what if you have like you know
16:51 you want something more responsive so
16:53 that's where the FR unit comes in so you
16:56 can see that FR unit it's basic
16:58 basically saying one fraction right so
17:02 if I only have one FR unit that's a
17:04 whole if I have one one FR it becomes
17:07 two halves if I do 1R and 1R and 1R it
17:11 becomes
17:15 1/3 um so here's some other examples so
17:19 if I do uh one you know one of R 1fr 2fr
17:24 so what it means is if you let's say you
17:28 add all of these that's 4 2 over 4 is
17:31 half 1 over 4 is a quar and 1 over 4 is
17:34 another
17:35 quarter um here you could think of it
17:38 more like so if we add them together
17:39 that's five so one over five is a
17:42 1 um and this is here 25 and two5 and
17:46 again if they're all the same um then
17:49 you have 1/3 of each
18:00 okay so let's
18:03 uh let's pull this in and let's take a
18:06 look at the FR FR
18:11 unit
18:13 can like to show the preview and then
18:16 actually copy
18:19 this into
18:25 Google all right let's take take a look
18:29 at what's going on here so here we have
18:31 uh six
18:34 items let's close out all
18:41 these
18:43 okay um and then you can see that in
18:46 these containers I've already set grid
18:48 to
18:49 them so that these two are already grids
19:02 so um let's take a look what happens if
19:07 we take the
19:10 first first one right so you can see
19:14 that we could set um let's choose
19:18 C1 and then let's just set the number of
19:21 rows so grid template rows um 85
19:25 PX 160 PX
19:35 and uh see let's do
19:40 C2 gr template
19:43 columns
19:47 20% 50 PX 120 P oops
20:02 okay um so here you can
20:07 see right
20:09 so see so here as you can see we um we
20:14 set these based off of uh pixels so we
20:18 set uh set
20:20 them uh 20% of the size 50 pixels and
20:25 120
20:27 pixels uh
20:30 so but you can see there's a bunch of
20:31 leftover space
20:33 here and so let's
20:36 see this 20% is flexible but these two
20:39 are not flexible you see as I open the
20:42 page wide and open the page smaller so
20:46 if I want this one to take uh one
20:49 fraction of the rest let's see what
20:51 happens
20:56 here so you can see that it Tak takes
20:59 up the rest of the space
21:02 here
21:03 so open and you close so the fraction
21:08 takes up one fraction of the rest of the
21:15 page um so for the first one I think it
21:20 will make more sense if we do
21:23 columns and Let's do let's try different
21:27 FR methods right so if we do
21:29 one so that just say we're making one
21:32 column that takes up one fraction so
21:35 what if we want to make two columns but
21:37 equally do half and half so we add one
21:39 more F FR you can see it equally uh
21:43 takes up half of the space and it will
21:45 adjust based off of the size it's really
21:48 cool here no matter how big or how small
21:52 my screen is it will take up exactly
21:54 half and half so if I do um one F again
22:00 you see it will divide you up into three
22:03 equal
22:08 spaces n is also equally spaced
22:13 out and it takes up 1/3
22:21 equally um so if I want to change one of
22:24 this uh to two FRS then you can see uh
22:28 you could think of this will take up
22:30 half of the space
22:31 here um and then these will be uh one qu
22:37 fourth no matter how big my screen is or
22:39 how small my screen is so that's a
22:41 really simple way to use
22:43 fractions to adjust the size
22:47 of adjust the size of your
22:55 grid all right so also Let's uh so for
22:59 the
23:01 bottom let's set
23:04 a grid templates
23:07 rows
23:10 oops to one F
23:18 FR and let's set a column so you can see
23:21 that
23:24 they're a little bit smaller here so you
23:27 can see um so you can see one of our it
23:31 basically because we didn't set a height
23:33 to our grid it only will take up as much
23:36 space as this grid height so let's go
23:40 ahead and set a height to our
23:47 container so if I set a height of
23:50 800
23:52 um you can see what happens is because I
23:56 only set the template roll one so let's
23:59 do it three times
24:03 right you can see It'll equally divide
24:05 up the height as
24:13 well it's pretty cool right here so
24:16 that's kind of what FR does it just
24:18 divides it um divides it in the grid
24:22 equally so no matter how tall or how
24:25 short your height is so I have 800 here
24:27 let's put it at 400 you can see even my
24:30 height is 400 I'll go ahead and just
24:32 adjust it to take up um exactly 1/3 of
24:35 the height here
24:38 so that is the
24:45 unit so any questions on the
24:51 unit and you you can also mix up FR
24:55 units of other types of units here so if
24:58 I take this right now I have three of
25:01 units but let's say I want to set the
25:02 first one to
25:04 20% you can see it automatically will
25:07 adjust and I set the middle one to maybe
25:10 200
25:13 pixels for some reason it's not
25:21 working I guess I can't do pixels and
25:24 fractions should be able to
25:30 see what's going on
25:35 here looks like we're not able to but we
25:38 can mix percentages and fractions I
25:40 think
25:43 um but yeah doesn't look like we could
25:46 do
25:47 pixels yeah but we could mix different
25:51 fractions percentages to create these
25:53 grids um the size that you want or need
25:56 them to be
26:07 all right any questions on the FR
26:10 unit it's a so you know if you think
26:12 about it it's just a really great way to
26:15 CU you know with these days you don't
26:17 know if your screen size are going to be
26:18 super large or super small the fraction
26:21 um unit allows you to just create like I
26:23 want this to be exactly one page all the
26:26 time um and I want these all to be equal
26:28 size or want this to be this much bigger
26:31 than this it just allows you to adjust
26:33 um the grid C uh the grid sizes um based
26:38 on like fractional
26:44 values okay um so let's talk a little
26:47 bit about uh the other
26:50 um CSS grid function so there are
26:54 Developer function helpers and this just
26:55 makes your coding easier and far more
26:57 efficient ient so there is one called a
27:00 repeat function uh is used to repeat the
27:02 number of columns and rows in the grid
27:04 layout and also the min max function
27:07 which defines a range between a minimum
27:09 size and a maximum size so we'll go
27:11 ahead and take a look at each one um
27:15 what they mean so the repeat function it
27:18 allows you to Define grid columns or
27:20 rows efficiently without manually
27:21 specifying each value so how it works
27:25 the syntax is you go uh you have your
27:28 template con or great template rows and
27:30 you repeat and you count and then the
27:34 size and then the same for the rows
27:35 count ins sides um so for instance you
27:38 know this as an example is if I have a
27:41 grid template columns and instead of
27:43 writing out 100 PX 100 PX 100 PX 100 PX
27:47 um I could write the repeat function
27:49 which means repeat four * 100 PX so
27:54 let's take a look how that looks in the
27:56 lab
28:06 smaller for
28:10 me okay so I'll go ahead and save
28:14 this and I'm going to open up the repeat
28:18 and Minimax
28:20 three uh let's close out all of these
28:25 too and uh Show preview I like to just
28:28 copy this just so I can put it
28:31 in all right go ahead and close out of
28:35 this for
28:38 now so you guys can see it
28:41 better
28:44 um all right so let's do the very basic
28:47 one so if I open the CSS into two Styles
28:51 and we're going to do number one right
28:54 we're going to we're going to um
29:00 we're going to start with
29:02 this this is C1 so go ahead
29:07 and select
29:10 C1 and I'm going to do grid template
29:13 column so I'm going to tell the number
29:14 of columns I want it to be four Columns
29:17 of 100 PX so I'm going to do 100
29:21 PX four times and so you can see now I
29:25 created a four column grid and each one
29:27 is 100 pixels wide but you know
29:30 sometimes you don't want to type out 100
29:32 PX four times so another way we could do
29:36 this is by typing out repeat and we're
29:39 going to say we want four
29:42 times 100
29:46 PX and so you can see this is exactly
29:49 the same thing and it will show you um
29:52 exactly same as the
29:55 top um I'm going to go ahead and
29:59 show you a repeat function with flexible
30:04 units right
30:10 so right here if we
30:14 select
30:19 C2 and we do grid temp The
30:24 Columns and we repeat three times *
30:29 1fr
30:32 this I'm going to repeat 3 *
30:39 1fr and so this is the equivalent of
30:42 writing out 1fr three times right so
30:45 we'll have
30:47 um we'll have these columns that equally
30:50 take up oneir of the space in this uh in
30:55 this container no matter if I'm this y
30:58 or
31:01 ifine this
31:05 small okay let's take a look what
31:08 happens if we do a
31:11 repeat uh with different values right so
31:16 let's just take this and see what it
31:23 does we temp The
31:26 Columns repeat
31:28 so what we're telling is we want to
31:30 repeat twice 100
31:34 PX okay so right now it creates two
31:37 columns at 100 PX and then we want to do
31:40 a
31:44 space and then we do 31
31:48 F so let's take a look and see what's
31:50 going on here right so what we're saying
31:53 here is we want the first two columns to
31:56 be 100 PX and then we want three columns
32:00 at
32:01 one so these last three columns it's
32:04 going to take up 1/3 of the space
32:07 each
32:08 um you can see it just fills out the
32:11 rest of these as these grid as well so
32:15 you could use repeat with different
32:24 sizes okay so you have two fixed columns
32:27 at 100 pixel each and then you have
32:29 three flexible
32:30 columns let's take a look at the next
32:38 one so can we use repeat with multiple
32:41 sizes so let's take a look at what
32:43 that's going to do so we're going to
32:44 choose uh
32:46 C4 and we're going to do the column
32:49 we're going to say repeat
32:52 twice 50 and one a far so let's take a
32:55 look at what this that does
33:00 so we want to do
33:02 twice 50 pixels 1
33:06 F okay so what's happening here is we're
33:11 saying 50 PX
33:15 1fr that's two column but you want to
33:18 repeat that two
33:20 columns twice right that's why you have
33:22 four columns
33:24 across so we take this and we repeat it
33:28 twice so you have four columns and then
33:31 it fills in the rest of the
33:39 grid like the last
33:43 one it looks like I have this I'm going
33:45 to delete that for
33:50 now okay so another thing you could do
33:54 is you can use repeat to define a
33:56 pattern for part of your grid and then
33:59 we added extra columns outside of the
34:01 repeat function yes
34:04 Angel could you repeat um what does it
34:08 mean the last part you you you explained
34:11 yeah that part yeah yeah
34:14 so if we take off this repeat right so
34:18 think of it this way we take off this
34:21 repeat essentially what we're telling it
34:23 is we're making a two column grid right
34:28 one that's fixed at 5050 pixel and one
34:31 one FR does that make
34:35 sense this
34:37 that okay but we're telling them to
34:40 repeat this one twice so if if I go back
34:45 so essentially what I'm saying is
34:48 repeat the fixed 50
34:52 pixel 1R repeat it one more time 50
34:55 pixel 1R
35:00 so think of it as a group we're
35:02 repeating this group
35:03 twice oh okay okay
35:07 yeah I know I had I first time I saw
35:10 that I was a little confused too but
35:12 that's um so basically you could create
35:16 uh you could say repeat you could create
35:18 your group here and then this is how
35:20 many times repeat that
35:23 group oh I see okay
35:28 um so we're going to do uh for C5 we're
35:30 going to see what happens if we uh do
35:33 this repeat and then we add one extra to
35:35 the end of it
35:44 so we're going to repeat twice this
35:48 group The 50px
35:50 1fr okay so we're we're it's the same as
35:54 the top but also this time we want to
35:56 add a 20% at the
36:00 end so now it
36:02 becomes a five column
36:05 grid so and you know this could be
36:08 anything you want it could be I believe
36:10 it could be in pixels
36:13 too yeah so that's that's and pixels is
36:16 fixed uh if you use percentage or
36:19 fractions those will be uh responsive so
36:22 this is how we could
36:24 create sorry so here what essentially is
36:27 saying we're repeating this group twice
36:30 51f 51f R and then at the end of the
36:34 repeating twice we're going to add
36:35 another column at 20% pix uh
36:39 20% so that's what happened
36:45 here okay before we do number six I'm
36:47 going to go back to lecture slide and
36:49 talk about mid Max but does anyone have
36:51 any questions on
36:54 this and of course right now we're just
36:56 using columns um just because it's
36:58 column has kind of like a whiff set to
37:01 it um with the row you could just
37:03 imagine it does it's pretty much the
37:05 similar except we'll have to set a
37:07 height to
37:10 our to our grid that's why we were doing
37:14 the
37:18 columns okay so that is the repeat
37:21 function it's just a a kind of a
37:24 shorthand and a way to think about um
37:27 creating columns or rows and just uh
37:30 putting them
37:31 together all right so the next one is a
37:34 min max function so the min max function
37:37 tells you like the minim so you know how
37:40 right now we're working with kind of uh
37:43 a fluid grid right but what if you don't
37:45 want the grid to be smaller than a
37:47 certain size or you don't want the grid
37:48 to be um larger than a certain size so
37:52 that's where the minmax function comes
37:54 in um and you you can set a minimum and
37:58 a maximum size for the grid columns or
38:00 rows so this ensures that the elements
38:02 remain responsive but they don't get too
38:04 small below certain size uh or you know
38:08 too large and so the syntax here is uh
38:12 for both The Columns and the rows you
38:14 write min max and then you Min is the
38:17 minimum size that you want and Max is
38:20 the maximum size uh you want so um can
38:24 see here for instance uh if we were to
38:27 do columns and we were to do two columns
38:30 here we have a the First Column we want
38:32 it to be a minim um we don't want it to
38:34 shrink smaller than 200 pixel uh we
38:37 don't want it to be bigger than 1fr um
38:40 and then the second column you don't
38:42 want it to be um 150 P smaller than 150
38:47 or larger than 2fr so let's take a look
38:49 at this what that actually
38:53 means um so here
38:58 so let's go ahead and let's go ahead and
39:01 actually take this example here right so
39:03 if we target
39:08 C6 oops wrong
39:11 one and we go grid template columns and
39:14 we do min
39:16 max 200f uh PX
39:20 1fr we do
39:23 space
39:25 Max 150 X comma
39:30 2R let's take a look if I was correct
39:34 all right so you can see
39:37 here
39:40 so as you can see the First Column we're
39:42 telling it we don't want it to be
39:44 smaller than 200 pixel and here we don't
39:47 want it to be uh smaller than 150 right
39:51 so when I stretch big enough it will be
39:55 this will be um so let's see what do we
39:58 have it so we had uh so there's three F
40:01 so this will be 1/3 and this will be
40:05 2/3 right and it will be responsive all
40:09 the way down until you hit 200 pixels
40:13 after that this will no longer get
40:14 smaller than 200
40:16 pixels so it's going to take the extra
40:19 space from here and it Go small until it
40:22 hits 100 pixels 150 pixels um and then
40:26 this will refuse to go smaller than 150
40:30 pixels so that's what the min max is um
40:33 so here I
40:35 have um so I'm going to go ahead and
40:38 comment this one out so you can
40:41 also use the minmax in the repeat so
40:45 what we're going to do here is let's
40:47 just do what it let's just try this one
40:50 um you could copy it paste it in okay
40:54 let's read it and see what it's saying
40:56 so what is saying is I'm going to create
40:59 two
41:01 columns and each column the smallest it
41:04 could be is 100 pixels and the largest I
41:07 want it to be uh is one to grow right
41:11 and then I'm going to add an extra 200
41:14 pixel fixed with here so no matter how
41:16 big or small I get that will be 200
41:20 pixel um so let's take a look you can
41:22 see when I'm big enough this takes up
41:25 half and half of the remaining space
41:27 but when I get
41:31 small um it should
41:36 stop you know the minimum at 100
41:40 which I'm
41:45 not quite sure if it does but it should
41:49 um minimum at 100 let's see if I try
41:52 this I do think that because to see if
41:56 it's a if if I so it was too small so if
41:59 I do 50 pixels you see because we force
42:03 this one at 200 um and this one would
42:06 say we don't want it to be smaller than
42:07 500 pixel that it will just refuse to be
42:11 smaller than
42:13 500 you can see so what happens is then
42:16 now I overflow because I'm forcing my
42:18 grid to be larger than the
42:23 container let me go ahead and make
42:25 this 100
42:28 um but you could go ahead and play
42:29 around with this and um kind of test out
42:33 the min max function and the repeat
42:43 function
42:49 okay all right so one thing about the
42:51 grid layout um we want to talk about is
42:54 the explicit grid and the implicit grid
42:57 so
42:58 um this is basically the ex explicit
43:02 grid is defined by the developer which
43:05 is us uh with grid template columns and
43:09 grid template rows and this means you
43:11 manually set the number of columns and
43:14 rows however there are when there are
43:17 extra grid items that doesn't fit into
43:19 defined explicit grid the browser
43:21 automatically generate additional rows
43:23 or columns to accommodate them so let's
43:27 see what this
43:35 means so I'll go ahead and save this so
43:39 we're done with three let's look at the
43:41 explicit let's close out
43:44 these so I'm going to go Show preview
43:47 and then copy this over into
43:53 here all right let's take a look at it
43:55 CSS for this one
43:57 um you can see I've already set a
43:59 display grid onto the containers so
44:02 we'll go ahead and let's take a look at
44:06 implicit and explicit grid right so if I
44:10 take this first container and I set a
44:13 grid
44:18 temp a grid template
44:21 columns and I want repeat let's do three
44:25 rows uh three columns at 150
44:29 PX okay so what you can see here
44:33 is I
44:36 specifically uh oh let's do rows for now
44:39 so grid template
44:41 rows and 150 PX so you could see here
44:46 what happened is I set the grid right so
44:49 the column is uh one two and three
44:51 columns so that's explicit I told this
44:53 grid I want three columns however for
44:55 the rows I I only set the first row so
44:59 you can see that this first three
45:01 they're considered the explicit grid um
45:06 however these are implicit grids I
45:09 didn't actually set the row height for
45:15 them so let's take a look at
45:21 here so as you can see here
45:27 right I set the I set these height at uh
45:31 150 150 by 150 however these ones um I
45:36 didn't set the height to them so the the
45:39 auto height so the but the but I still
45:42 have these items are in the grid right
45:44 so what happens is uh
45:47 um the the browser will fill in these
45:50 space and then because I didn't set them
45:53 the height would be uh whatever the
45:55 content is right so if my content is
45:59 this high and then I think I have a
46:01 little bit of padding around uh so my
46:04 font size 2m and then I do have a little
46:06 padding around them yes so you can see
46:10 it will be as tall as whatever my um my
46:13 content is so if I take away the padding
46:16 then you know it's only as tall as my um
46:19 content which is just the
46:23 numbers and this one it doesn't change
46:26 because I
46:27 specifically set the
46:36 height so it's important to understand
46:39 that there are explicit grid which is
46:41 what we said and then these are and then
46:43 the um the browser will fill in the rest
46:47 of these is is there any way that we
46:50 could put the numbers on the on the top
46:53 boxes in the middle of the boxes
46:58 I don't actually know these
47:04 are no I mean I'm not quite sure you're
47:07 saying can we put these numbers in here
47:10 right uhuh
47:11 yeah
47:14 um I don't see any options to do
47:18 that okay it's okay but yeah I mean you
47:21 could search online and see if there's
47:23 an option to do it but I don't I don't
47:26 think there
47:27 is
47:36 okay but yeah it would be nice if it's
47:38 in the middle but
47:42 uh
47:44 okay so how do we handle the size of the
47:48 rest of the rows right so rows or colums
47:51 that we did not specify the height
47:53 because sometimes you're not going to
47:55 know how many grid items you have so you
47:58 can control the size of implicit rows or
48:01 columns by using grid Auto rows which
48:04 defines the height of the rows created
48:06 automatically or grid Auto columns or
48:08 defines the width of the columns created
48:11 automatically
48:13 so uh so
48:15 again if if these weren't set then they
48:19 will automatically be the the size of
48:21 the content like we have here so let's
48:24 take a look how we can do this
48:27 so
48:29 um we have uh this let's say we want to
48:33 control the rest of these but we don't
48:35 know how many rows are going to be left
48:37 over so if we go grid template uh so
48:39 we'll go grid Auto
48:42 rows and we're going to set them at 100
48:45 and so now you can see what happens is
48:48 uh no matter how many rows I have here
48:51 it's going to go ahead and just set 100
48:53 to the rest of them so let's say I uh
48:59 just go ahead and just add a bunch in
49:01 here you can see that no matter how many
49:04 rows that are added um they're still
49:06 going to be the height of 100 so that's
49:08 what grid Auto uh rows will
49:16 do so let's see what happens if we take
49:18 away the first one now it's going to set
49:21 all of them right so you don't have to
49:23 set all of the explicit grid then you
49:26 know this now everything is implicit
49:28 grid because we didn't set any height to
49:29 any rows but by using grid Auto auto
49:32 rows uh we can set the rest of the
49:35 height of
49:38 these okay let's see
49:51 so so there is a short hand for this as
49:55 well um so there's something called grid
49:58 autoflow so that's a Shor hand of um how
50:02 grid items automatic get placed when
50:05 there are unassigned spaces in the Grid
50:07 or when items overflow the explicit grid
50:10 so grid autoflow so instead of you know
50:12 using the slide before where we did grid
50:14 Auto rows and grid Auto columns we could
50:17 just do grid autof flow and it will have
50:19 the row the
50:21 column um row dense or column dense and
50:26 so um here's definition so the row is
50:30 group items are placed row by row which
50:32 is left to right then WRA into the next
50:34 row column items are placed by column by
50:37 column Row D try to fill all the gaps by
50:40 back filling smaller items and column
50:43 dance similar to row dance but fill gaps
50:45 in the column base layout so we're
50:48 really just going to uh just use row and
50:50 column for now um I'm going to show you
50:52 guys
50:56 in the second
50:58 grid so go ahead here and let's uncommon
51:02 out the
51:09 C2 okay let's let me close this so you
51:12 guys can see a little bit
51:15 better uh okay so
51:25 C2 if we do grid
51:33 autoflow
51:36 column so when we do grid autoflow
51:39 column it just fills in everything into
51:43 the
51:45 column see
51:50 here and let's
51:52 set grid template columns to repeat
51:57 2 one
52:04 F grid template
52:19 rolls okay so what happened here is if
52:23 we do grid template columns and we're
52:25 going to repeat where we're going to
52:26 take up half
52:29 here um and then the last column you can
52:34 see but okay so what happened here is
52:38 let's go grid so we're telling it we're
52:40 only want two rows like we're so we have
52:43 uh the first row is 75 pixels and the
52:45 second row is 100 pixel um and then for
52:48 the columns um we are do we want two
52:53 columns where we so this right here is
52:55 the X a grid and so what it's going on
52:58 is it fills in the rest of the grid um
53:02 based off of the grid Auto flow so you
53:06 can see
53:07 here what it's doing is uh we explicitly
53:12 uh put this grid
53:14 together and because the autof flow is
53:16 in column it'll flow so here you know
53:19 it's a one two three which is the
53:20 default goes by row uh when we change
53:24 the autof flow it goes up down so one 2
53:27 3 4 and it'll fill in the rest of the
53:29 implicit
53:31 grid and then let's see if we add
53:35 in Grid Auto
53:41 column so if we want to want this column
53:43 to fill in um not Auto but we want to
53:47 maybe do
53:48 20% um and you can see then the rest of
53:51 the columns will be 20% so you can see
53:54 that there are ways for us to to
53:58 um
53:59 change you know use these to manipulate
54:03 how we want the grid to look
54:12 so so that's grid autoflow which is
54:14 we're changing how we want the grid to
54:18 flow um you know normally grid is 1 2 3
54:21 4 5 6 now we're going 1 2 3 4 5 6 so
54:24 let's take a look in our inspector what
54:26 happen happens when we put the layout
54:30 on so yeah I mean doesn't really so it's
54:34 still the same the numbering is still
54:36 the same 1 2 3 and then we have 1 2 3 4
54:41 as the line numbers it does the opposite
54:43 numbers as
54:46 well that's G grid autoflow
54:59 all right so that's different ways on
55:01 how we can build out our grid um next
55:06 we're going to talk about grid alignment
55:08 properties but before we do that do you
55:10 guys have any
55:12 questions on the grid I know a lot of
55:15 this will be um a lot of practice in
55:18 understanding how each of these can be
55:21 put together to work for you um but as
55:23 you can see it's very flexible it allows
55:25 you a lot more controlled and flex um
55:28 because you could grow uh build out en
55:30 higher
55:43 grid all right great so let's talk about
55:49 um alignment properties so grid also
55:53 just like Flex they have alignment
55:55 properties to control how the grid items
55:58 and entire grid are positioned within
56:00 the container so there are four key
56:02 alignment properties and they might
56:03 sound very familiar from flx you have
56:06 the Justified content which aligns the
56:08 grid as a whole horizontally align
56:10 content which aligns the grid as a whole
56:13 vertically justify items align
56:16 individual items inside the grid cells
56:18 horizontally and align items which align
56:20 individual items inside their grid cells
56:24 vertically um
56:27 and so let's start with justify content
56:30 it will align the whole grid
56:32 horizontally so it controls uh your grid
56:35 along the x axis uh where your grid as a
56:39 in general will
56:41 um will
56:43 be so it works when the grid container
56:46 is wider than its grid track so let's
56:48 just uh pull this in so kind of make
56:51 more sense what it what we're talking
56:53 about
56:54 so uh
56:58 oops so let's close this one out and
57:02 let's open this
57:11 one all right let's take a look at
57:14 what's going on here in our
57:16 CSS right so we have our
57:19 container which we set a height uh first
57:23 of all it's a grid um and we set a
57:25 height to it and then what we did was we
57:27 set a grid template columns in each of
57:30 these columns are 80 pixels so you can
57:33 see that there's a lot of leftover space
57:35 over
57:36 here
57:42 um and uh let's see what else we have
57:46 here okay
57:48 so that's it that's to note here that we
57:52 do have a lot of extra space and so
57:55 let's do this let's see what happens if
57:57 we take uh the first two
58:00 containers and we'll set a grid Auto
58:09 row okay so we're going to set the
58:11 height of all of these rows because you
58:14 know we only set the columns but we're
58:16 going to set the rows all to be 60 pixel
58:19 height so therefore you can see now
58:20 there's um Extra Space on the bottom as
58:23 well so then we're then we can start
58:25 using the these justify content and see
58:28 uh if our grid is smaller than our
58:30 container um how it would work so uh for
58:35 the first one we're going to
58:39 use uh justify content so if we justify
58:43 content
58:44 Center you can see our entire grid is uh
58:48 in the middle
58:51 of of this container so so this works
58:58 because because we set a certain width
59:03 to these These Are Fixed WID and there's
59:05 extra space uh in the container itself
59:08 so the items if we want them to be
59:10 centered uh we can use justify content
59:13 Center and we could try the rest of
59:15 these so we have start which is your
59:19 default on the left hand
59:22 side
59:24 and which goes to to the
59:26 end and then you have your
59:31 um space
59:33 between is very similar to
59:35 flex
59:38 right and then we
59:41 have space around again very similar to
59:45 the flex box and we'll do space
59:49 evenly you can see that it um spreads it
59:53 evenly so it's the same idea for the
59:56 line content except it's um it says
59:58 vertical
60:00 position
60:01 so if we go to
60:05 C2
60:08 content and let's do Center you can see
60:11 it's centers if this is only if the
60:14 height is larger uh the height of the
60:16 con the grid is larger than its uh items
60:21 inside so we C to start which is
60:27 the default end which we'll put it at
60:30 the
60:35 bottom space
60:40 between space
60:42 around and space
60:46 evenly so what if we do space evenly on
60:50 both
60:51 sides and you can see we have a grid
60:54 that space evenly
60:57 um within our container um both left and
61:01 right and also top to
61:09 bottom so that was justify content and
61:13 also align content which is very similar
61:16 to X the same similar
61:20 values so let's talk about justifi items
61:23 so it aligns items inside each each cell
61:27 horizontally and it controls the
61:29 horizontal line of grid items inside
61:30 your individual grid cells let's take a
61:34 look here if you go to index could
61:37 uncommon
61:39 out these
61:44 two
61:49 so let's take a look what's going to
61:51 happen if we take C3 which is this one
62:02 and we do uh justify
62:06 items
62:09 Center so you can see immediately when I
62:12 do justify item
62:13 Center uh my grid item uh now becomes
62:19 Auto with so but let's see what happened
62:22 what happened here okay so we are on
62:26 good container three so you can see if
62:29 I'm in this container so what happened
62:31 is my grid is still a certain size
62:34 however my content
62:36 inside inside my grid is uh horizontally
62:40 centered
62:41 here sorry horizontal centered yes
62:44 that's right so let's see what happens
62:45 if we do
62:48 start so you can see if this is my grid
62:51 I know it's kind of hard to see let me
62:53 see if I could choose a different color
62:59 oh that's much better okay um so you can
63:02 see here in my grid these grid lines
63:06 right it's uh the dash lines is the grid
63:11 and then just defy the items to the
63:15 start end right to the end of the grid
63:20 horizontally and I'm and then the
63:23 default which is stretch it's stretches
63:28 from take the
63:42 default all
63:44 right same thing with the line items is
63:47 the same
63:48 idea I'm going to do C4
63:57 start let's see now as as the Box
64:01 becomes as big even though the grid here
64:04 so let's put in this grid like the grid
64:08 is uh the size but the content inside
64:11 now since we did align items it's now
64:14 the size of your content so start we'll
64:18 put it on the
64:19 top Center will Center
64:22 everything and end we'll put it at the
64:25 bottom
64:27 I'm going to leave it at Center and see
64:29 what happens so stretch will be um the
64:32 default value here we're going to go
64:34 ahead and just leave it at
64:40 Center so that is a way for us to um
64:45 change the different um positioning of
64:49 where our grid content is within the
64:52 main content as well as you know within
64:55 each cell itself determining how to um
65:00 position our content within the
65:02 cell any questions on
65:13 this okay let's keep moving
65:22 on all right so we talked about grid
65:26 lines um so grid lines represent you
65:29 know uh the start of and the end of
65:32 between the column and row tracks so
65:34 each line starting from the start of the
65:36 track and in the direction of the grid
65:37 is number incrementally starting from
65:39 one so like we talked about this is grid
65:43 uh column one column two column 3 column
65:46 one column two and column three and uh
65:49 sorry row row line one row line two row
65:52 line three row line four um
65:56 so when we uh view
65:59 this in our layout we are able to see
66:03 each of these grid uh number numbering
66:08 and why is that important because we can
66:11 actually tell our grid where to start
66:14 and where to end so
66:17 um so what we're going to do here is let
66:22 me see if we're on okay so the next Lab
66:25 so we're going to um create a grid where
66:27 we're actually going to tell the grid
66:29 cell um where to start and then where to
66:33 end and then there's a shorthand too so
66:36 instead of writing out grid row start
66:37 grid row end you could just write grid
66:39 row start at number two and end at
66:42 number four or you could use a span
66:44 which means like I want this grid to
66:46 span to no matter where it is so let's
66:49 take a look how that works
67:00 oh okay so let's close out all of
67:04 these I'm going to grab this
67:12 link all right let's take a look at
67:15 what's going on here
67:18 um so essentially it looks pretty much
67:21 like the rest of your grid right um
67:24 except this time we have six and with
67:27 just this
67:29 one uh that's a different color than
67:31 everything else so that you could take a
67:33 look that when we target this one right
67:36 and I'm going to go ahead and turn uh on
67:39 the container so you can see there's one
67:41 2 3 4 and one two 3 turn it off for now
67:45 so if we
67:48 target this first item and we want it to
67:52 start a grid row start two
67:57 and grid row N three so if we take this
68:01 container overlay so we're talking these
68:03 are the row lines right we're telling
68:05 this we want this to start at row two
68:08 and end at Row three so if I do that
68:13 grid row start
68:16 two uh and then we wanted so you know
68:19 it's pretty much implied that ends at
68:21 three but let say we type it out uh
68:26 end three so you can see what happens is
68:29 now this will start at two and it will
68:32 end at three this great column it's
68:35 great so
68:38 um what if we want to move uh what if we
68:41 want it to start at grid column start
68:45 two and then uh column three so we want
68:49 to put it in this
68:51 position so we could also change the
68:54 column position
69:01 and again it's implied that the end is
69:03 at
69:06 three column and
69:11 three right so these are implied so if I
69:14 comment them out it's not going to
69:15 change where this ends up being we can
69:20 see that what happens is in the row
69:22 we're telling to start at the row line
69:24 two and we're telling to start at the
69:26 grid column line too so that puts it in
69:29 this position in our
69:34 grid um so can we do shorthand yes we
69:37 can definitely do shorthand so let me
69:43 comment let's comment all of them out I
69:46 was wondering how do you comment them
69:48 again I've totally forgot how to do that
69:52 um yeah on the Mac I will highlight the
69:56 ones I want to comment and I choose
69:58 command slash which is
70:02 um command plus
70:05 slash for a Windows I believe your
70:09 command is control control yeah
70:13 slash okay so I will highlight it or if
70:16 you just want it to be just this this
70:19 line you could just put anywhere on the
70:20 line and they will do it for you thank
70:23 you
70:25 I have a question uhhuh so um I I think
70:31 I'm I'm getting a little confused with
70:33 the
70:34 positioning and so when like the
70:37 exercise that you just did where the Box
70:39 wand went like
70:41 down
70:43 um it
70:45 that's why didn't like the rest of them
70:49 also like start from there if that makes
70:54 sense from here yeah like why didn't
70:58 like why wasn't two where six is uh I
71:03 guess because it has to fill in the
71:05 implicit grid um okay so if I yeah um
71:10 because if it's starts here then this
71:12 will all be empty space but the grid has
71:14 to be filled in right so what it does is
71:16 it moves everything else to fill in the
71:18 rest of the
71:21 grid okay I think I understand now thank
71:24 you
71:29 okay so let's shorthand this grid
71:32 roll
71:35 two and uh grid
71:38 column and let's say I want to move it
71:40 to between three and four so you can
71:42 actually do three slash4 and it moves
71:45 here so these are shorthanded makes it a
71:47 lot
71:48 easier to type rather than um what we
71:52 have up here
71:57 um so let's say we wanted to span two so
72:00 I let's change this to
72:03 two so you can see what happens is um
72:08 I'm telling it in the grid row I want to
72:10 start at two and it automatically will
72:12 end at three and this will also take up
72:15 just one space unless I tell it
72:17 specifically where to start so if I
72:19 wanted to start at two and end at four
72:22 it will span four um and I didn't see
72:24 who asked the last question but that was
72:26 a great question um what happens for the
72:28 rest of these is that they will fill in
72:30 the the gaps um the implicit implicit
72:34 grid so um the browser will
72:36 automatically fill in this grid um
72:39 starting from this it always starts from
72:41 the one one position um and then it'll
72:44 fill this in this because we only have
72:46 three columns the six will now be pushed
72:49 to the
72:51 bottom go ahead is it sorry no go ahead
72:54 go ahead
72:56 oh I'm going to go ahead and comment
72:58 this out also another thing you could do
72:59 is use the span um so if you don't tell
73:02 it where you start um you could so if I
73:06 do grid row and I do span two this see
73:11 it automatically spans two
73:13 rows and I could do grid column span
73:19 two and automatically span two so this
73:22 is really cool you could think uh
73:24 something times um if you know it just
73:27 makes it so simple for you to take
73:28 multiple columns um with just a really
73:32 simple
73:34 CSS
73:35 um
73:38 properties what I was going to ask you
73:40 is that um grid row and and grid row
73:48 start are kind of like the same right
73:51 because I was playing with it and it
73:53 does the same um action pretty
73:55 much yeah a grid row is the shorthand so
73:59 essentially what it's saying is grid row
74:01 is yeah I guess if you don't put the
74:03 ending in Grid row so grid row start I
74:06 don't think you could put an ending
74:07 number but in Grid row you could put an
74:09 ending number so like if I were to take
74:13 this
74:16 right so right now I'm saying grid roll
74:19 is two but I can't put it if I do a
74:21 slash I like a ending number here
74:26 let's say
74:27 four right but that's the difference
74:30 like grid row start so if you don't put
74:33 an ending number it's imply that you
74:34 only start at two but if you do put an
74:37 ending number then you could control the
74:39 end of it but grid row start does allow
74:43 like you're not going to be able to do
74:44 the SL oh okay so essentially the end
74:48 will allow you to do the grid
74:51 row like um expand yes so grid row is
74:55 short hand or
74:57 [Music]
74:59 these
75:02 yeah so it just it's it's more options
75:05 it's like saying and so it's like it's
75:07 like saying you could do padding top
75:08 padding right padding bottom and padding
75:12 left right um you could write each one
75:14 of them out or you could use just the
75:15 short-and padding so it's kind of like
75:17 the similar idea but you
75:20 can't you can't do
75:22 four four like you know padding and if
75:25 you just choose padding top you can put
75:27 four values in there got it so yeah it's
75:30 more selective when you do that yes
75:33 exactly exactly so this allows you to
75:35 put in more values um versus like this
75:38 one it's very just like you have one
75:41 value to put it's not going to read it
75:42 you put it St and
75:44 end okay
75:57 yeah and so here we have grid column
75:58 start and grid column end we already
76:00 talked about it um and then we have the
76:03 grid area which is actually shorthand
76:05 for everything right so so
76:09 essentially um you know we talked
76:12 about you know you could have each one
76:15 like grid column uh grid column start
76:17 grid column end grid row start grid
76:19 column uh grid row end so that's for
76:22 values that's a lot of typing or you can
76:24 you could actually just do uh grid row
76:27 or grid column that but that's still two
76:29 values you can actually combine all of
76:31 them and you could do so you could do
76:33 something called grid area so how it
76:35 works is grid area will be row start
76:38 column start row end and column end
76:42 so if we were to take go back here and
76:45 let's comment this one out so let's say
76:47 we want to do this one right where we
76:49 want it to span from 2 to 4 and 2 to
76:52 4 so what I can do
76:55 instead of typing all of these out I get
76:59 to grid
77:02 area
77:04 um so we
77:07 two
77:09 two right four
77:13 oops four and that's essentially the
77:17 exact same thing as this
77:19 one so we
77:23 got so let's say we want to go
77:26 from
77:29 two uh sorry two to four
77:32 row and we want to go from 1 to three
77:35 right so what if we want to take this
77:36 one so we take a row is 2 to four that's
77:39 fine so columns
77:43 one two three so that changes so you
77:46 could shorthand everything too of just
77:48 grid area
77:59 I have here on my notes that you could
78:01 also shorthand even with span so you
78:04 could do grid
78:06 row uh you start at two but you want to
78:10 span
78:12 three but that's a cool way of getting
78:14 the start and it's like you know I'm
78:17 telling you where to start but I want to
78:18 span
78:20 three and then we could do um R column
78:25 span
78:27 two it's pretty cool H guys can play
78:31 around with this and
78:34 um just see uh what will work for you so
78:38 this allows you lots of different
78:40 options for you to you know move your
78:42 grid the way that you want it to move
78:45 and you can imagine especially when
78:47 you're going from um like a desktop to a
78:50 mobile instead of like moving stuff
78:53 around or hiding and maybe displaying
78:56 some things you could just use the grid
78:58 to move things around to different um
79:01 different position throughout the
79:07 grid so it's a lot more powerful as you
79:10 can tell than the flex
79:18 box okay um before we move on do you
79:20 guys want to take a break or do you want
79:22 to keep going
79:25 and just put in the
79:29 chat see how much we have left
79:37 today um we're pretty much close very
79:39 close to the
79:41 end uh I think we're just going to talk
79:44 uh let's
79:48 see yeah so grid template area and grid
79:51 Gap are very simp uh so template areas
79:54 um be quick and then G app is very
79:56 simple and then we just have a final
79:58 example all right I got one person to
80:00 keep going
80:03 so
80:05 so so what I think is I'm going to get
80:07 through at least all of these and then
80:09 before the final example if you guys
80:12 don't want a break we'll take a break
80:16 um but I think that I really want to get
80:19 through a little bit more
80:30 all right
80:34 so yeah let's do a break before the
80:36 final example okay so um let's talk
80:39 about this um the really cool thing
80:42 about grid is this thing called grid
80:45 template areas and the grid template
80:47 Area Property it allows you to assign
80:49 names to different section of a grid
80:51 layout and you could use it to organize
80:54 and Visually structure your design so
80:58 how it works is uh you have to define
81:01 the grid area so the grid template Area
81:03 Property use a stream based layout to
81:05 find named regions so you can name
81:07 regions like main nav whatever you want
81:10 to name it um and then each row is a
81:12 separate string and each name correspond
81:15 to a CSS class that is assigned to an
81:17 element um and number two you assign the
81:21 grid areas to element use grid area name
81:23 and CSS to match element to the layout
81:26 so let's take a look at what this
81:28 actually means so what is here is um for
81:34 each section I can name it uh a certain
81:37 grid area and then I use the grid
81:40 template areas to um set up that
81:43 structure right so this could allow me
81:45 like very complex structure and then I
81:48 could use you know different grid
81:50 template properties to uh to assign how
81:54 big I want either the rows or the
81:56 columns right so for here um what I'm
81:59 saying here is I want header to take up
82:01 four columns nav to take up one main to
82:05 take up two columns one column aside and
82:08 then the phoo take up four columns so
82:10 let's uh let's take a look I think that
82:13 will make a little bit more sense um
82:17 once we get into here and see what it
82:20 means so
82:27 so we're on number
82:29 seven let's close out
82:33 everything show the
82:39 preview let's see what's going on here
82:41 all right so I have created like a
82:45 structure of let's say of a website so
82:47 you have your header your navigation
82:49 main aside and footer and right now it
82:52 just the say um they're all the same
82:54 height as um whatever the content is
82:58 inside and let's take a look at the
83:03 CSS
83:06 okay so there's nothing really on here
83:09 other than the body is a display grid
83:12 which makes everything inside the body
83:14 as you go into index so here's the body
83:16 and everything in here are now grid
83:18 items okay so what we'll do is we'll
83:21 start um by naming each one of these
83:25 grid items so I'm just going to name
83:31 them so the first one I'm going to name
83:34 grid header um so the area name it could
83:38 be whatever you want it to be um I like
83:40 to name it this way um and you could use
83:43 you know initials if you want but I like
83:46 to name it this way because it tells me
83:48 what this area actually is it makes a
83:50 lot more
83:53 sense so let's uh
83:56 just name each
84:00 one grid
84:03 area uh this is
84:09 me red area this name does uh
84:21 Na side
84:34 okay so now that I named everything kind
84:37 of just disappeared on the side because
84:39 I didn't add it to anywhere in the
84:42 body um but if I go into the
84:45 body and I use uh my grid template
84:50 areas oops
84:54 so how this works is you do col uh
85:00 colon and
85:02 then I do my first row so I want
85:06 header
85:07 [Music]
85:09 header header header so I'm saying I
85:12 want the header to span um four rows H
85:16 sorry three uh four
85:19 columns nap main
85:22 main side
85:25 and in
85:26 [Music]
85:29 footer okay so I think it's not showing
85:32 because I didn't set any template rows
85:35 so grid template
85:38 rows
85:39 um one fraction four fraction one
85:45 fraction oh shoot I put this on the
85:47 wrong one that's
85:50 why put it in their body
85:54 here we
86:00 go and uh what I'm want to set here is
86:04 because I didn't set a height to my grid
86:07 um you can see that it just is as big as
86:10 um what I set it here so let's set the
86:13 body
86:14 to
86:16 um see 100% will give me
86:20 anything no so uh let's do 100 V8 which
86:24 stand for the viewport height which will
86:27 make my body as high as my viewport you
86:30 can see if I close this out so what's
86:33 happening here
86:36 is so I chose the header and I'm I said
86:41 I'm going to name this header right and
86:43 I'm going to name this main section grid
86:46 main navigation um as
86:50 nav uh grid area aside as a side and and
86:54 grid area footer and then what I'm doing
86:57 is I'm going into the body which has the
86:59 display grid and I'm using these
87:03 names to set the columns right so I want
87:07 the header to span four
87:09 columns um and then then not to span one
87:12 column main to uh main to be two columns
87:15 the side to be one and then further to
87:18 span four
87:20 columns and then uh what I did was see
87:24 what happens if I get rid of these so if
87:26 I get rid of this it automatically just
87:28 looks like they're all the same same
87:31 size but I want this to be uh so what I
87:35 do is I'll add them all up 1+ 4 + 1
87:38 that's six right so uh the first one
87:40 will be one six of the area uh 4 six
87:44 will be about 2/3 and then this is one
87:46 six of the area so you can see and
87:49 another thing what I did was I had to
87:51 set the height of the body um otherwise
87:54 going to it's not going to take up this
87:56 full width for the height I set 100 of
88:00 the viewport height here so um you can
88:04 see what I did was because I uh set
88:07 these grid areas uh I'm uh I set a name
88:12 to each one I could use the name to
88:13 create very
88:15 complex um
88:18 complex
88:20 um templates so let's say like here I
88:24 want a side to actually take two and
88:26 Main to only take one and I just
88:34 um do this and why a side
88:40 on okay so you know
88:43 it's because
88:48 um the problem uh main content is a lot
88:51 larger than the side so it can't be too
88:53 much smaller than the actual content
88:56 inside of it but
88:58 um it gets
89:01 smaller um so you can see that this
89:04 can't get smaller than whatever the
89:06 content is inside of it so that's kind
89:08 of a downside to it but if I get big
89:11 enough you can see that like um this is
89:15 definitely taking up a lot more space so
89:17 you could use this method to
89:22 um to
89:24 a little bit more
89:28 complex
89:33 templex
89:37 okay all right so the last thing is we
89:39 do have the Gap property that's very
89:41 similar to um the flex Gap so um again
89:48 you have the row Gap the column Gap or
89:50 just the Gap property itself which is
89:52 the row and the column and so so let's
89:54 uh pick this do this last lab and then I
89:57 will we um do the final lab after this
90:01 which will kind of put everything that
90:03 we learned
90:04 together and uh you'll see it in more of
90:07 like a final example so let's go ahead
90:10 and take a look here so let close out of
90:13 all of
90:16 these yeah then I'm going to grab this
90:19 one and this a gap is very similar to
90:23 flat X
90:29 um so let's
90:34 see right so this container as you can
90:37 see is this display grid already and
90:40 what I set here is
90:43 um one column where the where the
90:46 minimum is 160 and the maximum is 20%
90:50 and then I'm repeating uh onef so the
90:52 remaining space I'm taking half and half
90:54 so this two columns will be equally in
90:57 size so this is a three column grid they
90:59 come in and out you can see it doesn't
91:01 get smaller than 160 over here um and
91:05 when it gets larger it will get larger
91:07 than
91:09 20% okay so what I want to do here is if
91:12 I want to add
91:15 just a gap of 20 pixels so now it adds
91:21 um oops it adds the gap
91:24 um one thing to know about the Gap it
91:26 doesn't add it outside here it only adds
91:28 it in between each of these similar as
91:31 Flex box um and so when I do 20 it just
91:35 automatically does 20 on the column and
91:37 uh 20 on the row if I want to do I can
91:40 separate them so I'm going to comment
91:42 this one out if I want to do roll
91:47 Gap uh 20
91:50 pixels you can see here automatically in
91:52 my roll add the
91:55 Gap and you could do column
92:00 Gap uh P pixels and so you have 20 and
92:04 10 or you could
92:05 [Music]
92:07 shorthanded right shorthand for this one
92:09 is the same Gap 20 pixel for the uh roll
92:13 and
92:18 10 oh and that's it for everything and
92:22 then uh let's take a
92:27 minute I don't want to take too long of
92:29 a break with a 10 minute 10 minute break
92:33 be too much we could do a five minute
92:35 break and then we'll talk and then we'll
92:37 come back and do the final example so a
92:40 little bit more let's come back at 8:20
92:42 so um 8:20 we'll come back and
92:46 um we'll start off again and we'll
92:49 finish example and then we'll get into
92:50 our teams
93:04 all right I'm back guys all
93:16 back
93:19 yes
93:22 yep all right so I wanted to
93:27 um uh before we start the last one
93:30 there's a little bit more in the grid
93:32 that I want to talk to you uh talk about
93:35 um so uh this is justify self align self
93:38 and order so it's very similar to
93:40 flexbox when you justify yourself you're
93:43 telling um the property itself instead
93:46 of the entire everything um aligning a
93:48 certain way you're telling a
93:50 certain um certain grid it
93:54 how to align uh specifically the
93:57 horizontal alignment in the item so
93:59 that's justify self um and again it's
94:02 the same as if you do justify item um on
94:05 the container which is Start Center end
94:08 and stretch and then we have align self
94:11 which is the vertical alignment of an
94:13 item and start Center end and stretch um
94:16 and the last thing and we will show this
94:20 in the last example is order so you
94:22 could tell the gri item where to order
94:25 to um so for instance a default value
94:29 for everything is zero so if you uh a
94:33 higher value will appear later in the
94:34 grid and a lower value will appear
94:36 earlier so for instance and you can do a
94:39 negative also so the default value is
94:41 zero if you order something that's a
94:43 negative one it's going to go to the
94:44 beginning of the grid uh anything higher
94:47 it's going to go uh later in the grid so
94:50 um let's do this last
94:54 and you guys can see my screen right
94:56 want I make
95:00 sure awesome okay sometimes I can't tell
95:04 usually there's a green outline but
95:05 there's no outline sometimes
95:08 um all right so let's go to lab
95:14 n and let's take a look at this lab
95:21 so I'm going to again hold my my Chrome
95:24 to the side here and I will uh grab the
95:29 preview of
95:35 this close this
95:40 out um and let's take a look what's
95:43 going on here right so we have this
95:47 index and it's very uh simple so we have
95:50 our section and we have our body and in
95:53 the body there's one section and this is
95:55 our container um in the section there's
95:58 a header which put the H1 horses we have
96:01 our main uh and in the main we have two
96:04 figure elements so we have um in the
96:08 figure we have an image we have a fit
96:10 caption and then we also have uh a
96:14 paragraph and we have two of these going
96:17 on um and then we have our footer right
96:20 here on the bottom
96:24 um so in this style you can see we have
96:27 uh just a header there's a text Aline
96:29 Center and we put a background color on
96:31 there um and we added a background color
96:35 to everything in the main area here so
96:39 we used Main and then this means
96:41 Universal so everything under main um as
96:44 a child uh it's going to have a
96:46 background color uh the article
96:51 uh has a font style metallic and a
96:54 padding of 2
96:56 RM
96:58 um which doesn't look like it's
97:00 affecting right now but the image has a
97:02 max width of 300
97:05 pixels uh which means it can only be as
97:08 uh as big as 300 but then 100% to fill
97:11 in that 300 WID uh and I said aspect
97:14 ratio of one which means that they're
97:17 squares uh the
97:19 figure which
97:21 is uh
97:24 let's see here which is this entire area
97:27 has a padding around it uh and a margin
97:30 of zero a fit caption which was this we
97:33 added a background color font weight
97:35 bold align the center and then we added
97:37 a height to
97:39 it uh for the paragraph we added a Max
97:42 width of 300 margin Auto to center it
97:46 and then also some padding up and down
97:49 and then we have our footer where we
97:51 added a background color
97:54 a texal line Center and then a padding
97:57 of one RM so the goal here is we are
98:01 going to use grid to
98:06 um to uh set this up in the positions
98:10 that we want it to be so
98:14 let's start so we're going to start by
98:16 taking this main which is this entire
98:19 middle section
98:24 uh and then we're going to do display
98:30 grid which as you can see display grid
98:33 doesn't do anything except it creates
98:35 everything in the
98:36 main the direct children of main will
98:40 now become
98:42 um grid items so if I go into
98:47 inspect and you click main so you can
98:49 see uh under the layout if I click Main
98:54 um which is this area you can see then I
98:56 have my grid here can see the grid
99:00 lights are very difficult to see
99:04 here really dark okay so then you can
99:07 see you have my grid which is uh the
99:10 first figure here the second figure here
99:13 and then on the bottom I have my
99:16 article
99:18 okay and uh I want to set some uh
99:22 columns and rows
99:24 so I'm going to do a
99:27 grid template
99:29 columns and I'm going to so what I want
99:32 is um two columns and I want them to be
99:37 equal uh with so repeat 2 onef FR so
99:45 then now you can see suddenly I have my
99:48 um grid side by side
99:54 and I want uh three
99:57 rows great template
100:00 rows
100:02 repeat so I'm setting the explicit row
100:05 but I'm going to set them as Auto
100:08 height so it will just be the exact
100:11 height as um the content
100:14 inside you can see
100:16 here so the first thing I want to do is
100:20 um I want this article to span uh my
100:24 grid uh two columns so I'm going to go
100:28 here where it says main article and I'm
100:31 going to
100:32 set a grid column I wanted to span two
100:38 columns close this out so you can see
100:41 because it doesn't
100:43 live okay so that's great I I C uh my
100:47 grid and then what I want is I don't
100:50 want this on the bottom I actually want
100:51 this at the top so what I'm going to do
100:53 is I'm going to uh set an
100:56 order and remember all the order for
100:59 everything default is zero so if I want
101:01 it to be above everything else so
101:05 imagine this is one this is two and this
101:08 is three if I want three to be above one
101:10 and two and these are order Z 0 I just
101:13 do a negative
101:14 one and that's going to move my article
101:16 to the top
101:22 here so what I want to do also
101:27 is
101:29 um you could do a grid within the grid
101:32 so I want these to be grid also so I can
101:35 go ahead and U manipulate the different
101:39 um their positioning and stuff inside so
101:44 uh these are the figures so I'm here in
101:46 figure I'm also going to change it to
101:48 display grid so let me show you before
101:51 and after so if I inspect here right
101:54 right now I only have one grid and this
101:56 is on the main there's no grid on this
101:59 at this moment so if I take the figure
102:01 and I do display
102:04 grid you see suddenly and you know I
102:06 could so I have two figures so let me uh
102:09 uncheck the name so you can see what's
102:10 going on here so suddenly these have now
102:12 become grids as well
102:16 um and I want all the content to be
102:19 centered you can see that it's kind of
102:20 weird that this is uh left the line so
102:23 I'm just going to do justify content
102:27 Center so when I do justify content
102:31 Center um suddenly this this um is only
102:35 as big as um everything is as big as the
102:39 largest size item which is the 300 um
102:43 and that kind of it fixed the issue that
102:46 we had overflowing with these being
102:48 bigger than the image
102:56 and then let's do grid template
102:59 rows uh I'm going to do
103:02 auto so we want to set two of
103:05 them um one so we're going to just set
103:08 the grid template rows for now um so
103:11 what I want to do here is I want this
103:15 um big caption to um
103:20 overlay this um this image right so I
103:24 want to Overlay it on top so what I want
103:27 to do here is I'm going to select both
103:30 the image and the
103:33 figure sorry fit caption the image and
103:36 the Fig so the image and the fit caption
103:39 so if I come here and I do image comma
103:42 fit
103:44 caption and um
103:49 actually let's take this off for now so
103:52 if I want them both to be the
103:55 same uh I could do a grid
104:01 row starting at
104:03 one and ending at two for both of
104:08 them and then I want them both to have
104:11 the grid
104:13 column to start at one and end at
104:17 two and you can see that it overlays
104:21 here it's great
104:23 um I added this here to set up the
104:27 explicit explicit row
104:31 um so you can see if I didn't set it
104:35 then um it adds a little Gap here but if
104:38 I set it in Auto it it I'm telling it I
104:42 want two rows um you know I don't want
104:45 them to implicitly add rows um I want
104:47 this one to be Auto sized and I want
104:49 this one to take up the rest of the
104:51 space that's in here and so I have this
104:54 overlay um except that this fit captions
104:58 at the top I don't want it to be at the
105:01 top so I want it to be actually at the
105:04 bottom here so uh I have here F cap
105:08 we're going to use the Align celf so
105:09 we're going to tell align cell because
105:11 we have we can't use align items because
105:13 there's two things in the same cell um
105:17 so we're telling the fit caption to
105:19 align
105:21 self and align self remember it's the
105:24 vertical alignment versus if we do
105:25 justify self it's the horizontal and we
105:28 want it to be at the end so you can see
105:31 that push it to the end overlay
105:37 here
105:42 okay
105:44 so let's see
105:47 I have also
105:48 [Music]
105:51 here see I I have a note to do let's see
105:54 if we do um main
105:59 paragraph align self start where is
106:03 that that doesn't really do anything
106:07 know why I have that let's see
106:14 height okay so I think I was having an
106:16 issue here with um with them being
106:19 different so I guess that's why I added
106:22 it
106:23 okay so you see here that um right now
106:27 the text are um kind of different
106:32 heights right because this one has a
106:34 little bit more text than this one and
106:37 so you can see the gap between these are
106:39 different so I wanted them to both be at
106:42 the top uh of each one so I wanted the
106:46 paragraph to also be a line self um and
106:49 so I added a line self to the start to
106:52 make it at the top of it uh and I had to
106:54 set a height to the grid cell in order
106:56 for it to actually align
106:59 um and so but then I wanted a bit more
107:03 gap between the top and the
107:05 [Music]
107:06 bottom so I added a gap one
107:11 R oh actually so I added a gap just to
107:16 um see okay so I wanted to show you guys
107:18 what the Gap does so if I add a gap
107:21 inside this Main it added some space in
107:24 between each of these section here so
107:28 um you can see here if if you know if
107:32 these were boxes that
107:35 were smaller and you wanted to add some
107:38 space in between the boxes you can add a
107:40 little Gap
107:43 there and that's it any questions on
107:47 this how
107:50 to use Gap or I mean use uh grid so it's
107:55 a lot of uh different properties um that
107:58 you could use to um you know just
108:02 uh position things and just a lot easier
108:06 that you know stuff that you use float
108:09 or you use like negative margins or
108:11 things like that it's uh it can get to
108:13 be a lot of cod versus it's a lot
108:15 simpler this way to be able to adjust um
108:19 different spacing and how to get these
108:22 uh grid items to show the way that you
108:24 want it to
108:25 show all right so for this week uh we
108:29 just have um let's take a look what we
108:32 have this
108:35 week so uh we are done with layout and
108:38 positioning starting next week we are
108:40 doing uh responsive web design uh so
108:44 we're going to so there's a quiz this
108:45 week for CSS layout and positioning um
108:49 there is one assignment and there's two
108:51 parts to assignment the first one is
108:53 just a couple different exercises for
108:55 you to practice the different grid
108:57 layouts um and there's a couple
108:59 requirements as well as there is um
109:02 images of how your grid should end up
109:05 looking like um so there are three
109:08 different exercises for you to just
109:09 practice these grids uh in part two
109:12 we're going to be building out the
109:13 community community page um so you are
109:17 provided uh starting code and the idea
109:20 is to use grid um to to create this
109:24 layout specifically um in the community
109:26 page and again we're not doing
109:28 responsive design just yet so it just
109:30 has to look this way on desktop and you
109:32 don't have to worry about how it looks
109:34 on
109:36 mobile any questions