All language subtitles for 112 Setting Up a Reusable Grid.en_US

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,480 --> 00:00:02,780 In this lecture, 2 00:00:02,780 --> 00:00:06,950 we're going to use CSS grid in order to set up a grid 3 00:00:06,950 --> 00:00:08,760 that we're going to be able to reuse 4 00:00:08,760 --> 00:00:11,493 over and over again on our page. 5 00:00:13,310 --> 00:00:17,240 And let's start by adding some HTML here. 6 00:00:17,240 --> 00:00:19,610 So I will actually add now with the next section 7 00:00:19,610 --> 00:00:20,830 that we're going to build, 8 00:00:20,830 --> 00:00:22,993 which is the, how it works section. 9 00:00:23,850 --> 00:00:26,490 So here we have the section hero 10 00:00:26,490 --> 00:00:28,330 and then after that, 11 00:00:28,330 --> 00:00:31,473 but of course still in the main part of the page, 12 00:00:32,810 --> 00:00:35,300 we're going to have another section 13 00:00:35,300 --> 00:00:36,220 which is called 14 00:00:37,700 --> 00:00:39,430 section how. 15 00:00:39,430 --> 00:00:43,930 so, which stands for how it works basically. 16 00:00:43,930 --> 00:00:45,530 Okay. And now here, 17 00:00:45,530 --> 00:00:49,000 I will simply add a couple of div elements 18 00:00:49,000 --> 00:00:51,680 just so I can show you the reusable grid 19 00:00:51,680 --> 00:00:54,630 that we're going to create in this lecture. 20 00:00:54,630 --> 00:00:59,110 So test one let's just copy this, 21 00:00:59,110 --> 00:01:01,960 or actually let me show you an even better trick, 22 00:01:01,960 --> 00:01:03,320 than copying it, 23 00:01:03,320 --> 00:01:08,320 which is using this command right here in the selection menu 24 00:01:08,950 --> 00:01:11,540 And then copy your line down. 25 00:01:11,540 --> 00:01:13,990 So this is something that I use all the time. 26 00:01:13,990 --> 00:01:17,280 And so I even created a special shortcut for it, 27 00:01:17,280 --> 00:01:18,130 but for you, 28 00:01:18,130 --> 00:01:21,510 the shortcut should probably be similar to this one here. 29 00:01:21,510 --> 00:01:23,680 So that is alt or option 30 00:01:23,680 --> 00:01:26,810 and then shift and the arrow up key. 31 00:01:26,810 --> 00:01:28,100 But for copying down, 32 00:01:28,100 --> 00:01:31,553 it is option or alt shift arrow down. 33 00:01:32,700 --> 00:01:35,423 So watch what happens when I click here, 34 00:01:36,270 --> 00:01:39,183 so basically it will simply duplicate this line. 35 00:01:40,290 --> 00:01:42,693 And so I do this a couple more times, 36 00:01:44,450 --> 00:01:45,420 and this is again, 37 00:01:45,420 --> 00:01:49,670 something that I do all the time when working in VS code. 38 00:01:49,670 --> 00:01:50,780 Okay. 39 00:01:50,780 --> 00:01:53,693 Now let's just quickly a style those. 40 00:01:55,620 --> 00:01:57,320 So something just temporary, 41 00:01:57,320 --> 00:01:59,403 which we will delete a bit later. 42 00:02:03,820 --> 00:02:06,483 And actually let's style the section, how as well. 43 00:02:08,650 --> 00:02:10,220 So instead of just doing that later, 44 00:02:10,220 --> 00:02:12,283 I'm going to do that immediately here. 45 00:02:13,420 --> 00:02:16,890 And so that I will do down here because of course, 46 00:02:16,890 --> 00:02:20,550 we're going to need some additional code for this section. 47 00:02:20,550 --> 00:02:24,920 So I'm also copying here this comment 48 00:02:24,920 --> 00:02:28,383 so that we can create a nice additional code block here. 49 00:02:29,960 --> 00:02:33,530 So the how it works, section 50 00:02:33,530 --> 00:02:36,900 and then here let's add a padding, 51 00:02:36,900 --> 00:02:38,340 and I will do the same padding 52 00:02:38,340 --> 00:02:41,160 that I also used on the hero section. 53 00:02:41,160 --> 00:02:45,130 So 96 pixels on top and bottom, 54 00:02:45,130 --> 00:02:47,303 and then zero on the sides. 55 00:02:48,480 --> 00:02:49,810 And for now let's just give this 56 00:02:49,810 --> 00:02:51,360 some background color actually. 57 00:02:54,310 --> 00:02:55,823 Let's say orange, red. 58 00:02:57,560 --> 00:03:00,073 Okay and now just giving those four, 59 00:03:00,930 --> 00:03:02,633 also some background color, 60 00:03:03,690 --> 00:03:05,850 just so we see them. 61 00:03:05,850 --> 00:03:08,180 So I can say here first, 62 00:03:08,180 --> 00:03:10,980 or actually the nth child, 63 00:03:10,980 --> 00:03:12,280 and then the first one 64 00:03:15,170 --> 00:03:16,323 background color, 65 00:03:17,660 --> 00:03:19,230 let's go with this one here 66 00:03:19,230 --> 00:03:20,270 and now I will again, 67 00:03:20,270 --> 00:03:23,030 use that shortcuts to duplicate the line. 68 00:03:23,030 --> 00:03:26,053 So that is shift option and arrow key down. 69 00:03:29,960 --> 00:03:33,620 So number two, three and four 70 00:03:37,260 --> 00:03:38,663 here let's use blue, 71 00:03:41,570 --> 00:03:46,533 violet and maybe some yellow color. 72 00:03:48,350 --> 00:03:50,853 Okay. Just quickly checking it out. 73 00:03:52,170 --> 00:03:53,883 Oh, somehow that didn't work. 74 00:03:54,780 --> 00:03:57,920 Oh, and indeed here, 75 00:03:57,920 --> 00:04:00,050 we only have one section, how, 76 00:04:00,050 --> 00:04:03,470 so of course I want to select the nth child 77 00:04:03,470 --> 00:04:05,683 of the div elements that are in there. 78 00:04:08,250 --> 00:04:12,150 So let's add that in all of these. 79 00:04:12,150 --> 00:04:13,443 That didn't work somehow. 80 00:04:18,250 --> 00:04:19,253 Now that's better. 81 00:04:22,720 --> 00:04:26,233 Let me just give them some padding here. 82 00:04:30,180 --> 00:04:31,240 And this is temporary, 83 00:04:31,240 --> 00:04:32,880 so we can just use pixels 84 00:04:33,950 --> 00:04:38,563 and also the font size of even something like 50 pixels. 85 00:04:39,640 --> 00:04:40,800 Okay. 86 00:04:40,800 --> 00:04:42,780 But now let's say that if we wanted to arrange 87 00:04:42,780 --> 00:04:47,120 these four here in a two by two grid, for example. 88 00:04:47,120 --> 00:04:49,440 So how would we do that? 89 00:04:49,440 --> 00:04:53,480 Well, we could of course go back here to our section how, 90 00:04:53,480 --> 00:04:56,740 and then set up that grid. Right? 91 00:04:56,740 --> 00:04:58,990 However, we would then write that code 92 00:04:58,990 --> 00:05:02,170 maybe multiple times over and over again 93 00:05:02,170 --> 00:05:04,670 in different parts of our website. 94 00:05:04,670 --> 00:05:07,160 And so that's something that we want to avoid. 95 00:05:07,160 --> 00:05:10,363 And so instead I will actually create a reusable grid. 96 00:05:11,710 --> 00:05:14,030 So that's the whole point of this lecture 97 00:05:15,240 --> 00:05:18,043 well, let's do it right here for now. 98 00:05:19,370 --> 00:05:22,340 So I will simply create a new class here, 99 00:05:22,340 --> 00:05:23,790 which I'm going to call grid. 100 00:05:26,680 --> 00:05:29,493 And then of course I will make it a grid container. 101 00:05:32,250 --> 00:05:37,250 And let's also add some gap here, maybe again, 9.6 REM, 102 00:05:39,130 --> 00:05:42,640 and here it needs actually to be REM as well of course 103 00:05:42,640 --> 00:05:43,743 not pixel. 104 00:05:45,150 --> 00:05:48,260 And I said that I wanted a two by two grid. 105 00:05:48,260 --> 00:05:49,853 So that means two columns. 106 00:05:51,000 --> 00:05:55,040 So grid, template, columns. 107 00:05:55,040 --> 00:05:58,000 And so let's actually use the repeat function 108 00:05:58,000 --> 00:06:03,000 and then saying that we want 1fr twice. 109 00:06:03,070 --> 00:06:05,530 So remember that this is the exact same thing as 110 00:06:05,530 --> 00:06:09,163 writing 1fr, 1fr right? 111 00:06:10,410 --> 00:06:12,090 Okay, and so this, 112 00:06:12,090 --> 00:06:13,703 now we can add here, 113 00:06:16,280 --> 00:06:17,113 right? 114 00:06:17,113 --> 00:06:19,800 And so now the section how, is also a grid 115 00:06:19,800 --> 00:06:23,350 and so this code also applies now to this element. 116 00:06:23,350 --> 00:06:25,430 And so if we give this a a safe, 117 00:06:25,430 --> 00:06:27,780 then we should have our grid 118 00:06:27,780 --> 00:06:29,863 and indeed here it is. 119 00:06:30,710 --> 00:06:31,543 Right? 120 00:06:32,910 --> 00:06:37,020 Okay, but this is actually not really reusable yet 121 00:06:37,020 --> 00:06:39,773 because let's say that we have another section then, 122 00:06:41,020 --> 00:06:43,143 let me just copy it here, why not? 123 00:06:45,400 --> 00:06:47,290 So now we have it twice here 124 00:06:48,630 --> 00:06:52,130 and indeed it's exactly the same thing, 125 00:06:52,130 --> 00:06:53,470 but let's say that this one here, 126 00:06:53,470 --> 00:06:56,840 I actually wanted it to have three columns. 127 00:06:56,840 --> 00:06:58,393 So what would we do then? 128 00:06:59,270 --> 00:07:01,120 So we cannot change this one 129 00:07:01,120 --> 00:07:02,840 because the first grid here, 130 00:07:02,840 --> 00:07:05,230 we still want it to be two by two 131 00:07:05,230 --> 00:07:08,360 only this one here should have three columns. 132 00:07:08,360 --> 00:07:09,300 Right? 133 00:07:09,300 --> 00:07:12,330 And so the way to make this really reusable 134 00:07:12,330 --> 00:07:14,880 is to basically export that style 135 00:07:14,880 --> 00:07:18,210 from the grid and create yet another class 136 00:07:18,210 --> 00:07:22,010 that we can then add here and here. 137 00:07:22,010 --> 00:07:24,283 So let me show that to you in practice. 138 00:07:25,790 --> 00:07:28,020 So grid, and then here, 139 00:07:28,020 --> 00:07:30,200 I like again to use these two dashes 140 00:07:30,200 --> 00:07:34,080 to say that this is a variation of the original, 141 00:07:34,080 --> 00:07:37,220 so grid 2-cols, 142 00:07:37,220 --> 00:07:39,330 which stands for two columns. 143 00:07:39,330 --> 00:07:42,423 And so here we will now add this code. 144 00:07:44,810 --> 00:07:45,900 Okay. 145 00:07:45,900 --> 00:07:50,900 And then we can copy it and say, grid three columns. 146 00:07:52,030 --> 00:07:55,773 And then here, we of course want to repeat this three times. 147 00:07:57,300 --> 00:08:00,103 So can you see what we're going to do now? 148 00:08:01,630 --> 00:08:04,110 Well, now we just have to add grid 149 00:08:04,110 --> 00:08:07,940 2-cols here to this class list 150 00:08:07,940 --> 00:08:12,940 and then here grid 3-cols. 151 00:08:13,030 --> 00:08:14,620 And so with this we're going to achieve 152 00:08:14,620 --> 00:08:16,013 exactly what we wanted, 153 00:08:17,580 --> 00:08:18,530 right? 154 00:08:18,530 --> 00:08:21,440 So our first grid is a two-by-two. 155 00:08:21,440 --> 00:08:23,020 So with two columns 156 00:08:23,020 --> 00:08:26,940 and the second one has three columns, right? 157 00:08:26,940 --> 00:08:30,610 And so now our grid element here is way more versatile 158 00:08:30,610 --> 00:08:32,330 all over our page. 159 00:08:32,330 --> 00:08:34,600 So we can use it in different situations 160 00:08:34,600 --> 00:08:38,210 and then simply use this other variation 161 00:08:38,210 --> 00:08:40,050 of class here basically 162 00:08:40,050 --> 00:08:43,730 to create a grid with two or three columns, 163 00:08:43,730 --> 00:08:45,950 or we might even need four columns 164 00:08:45,950 --> 00:08:48,003 and so that is very easy as well. 165 00:08:49,270 --> 00:08:51,760 So let's say here we wanted actually four. 166 00:08:51,760 --> 00:08:54,400 And so here we go. 167 00:08:54,400 --> 00:08:55,933 So now it is columns. 168 00:08:57,310 --> 00:09:00,300 And we can of course also see that nicely 169 00:09:00,300 --> 00:09:03,683 in the dev tools where we see of course, 170 00:09:05,940 --> 00:09:08,410 or actually here the parent, of course. 171 00:09:08,410 --> 00:09:11,230 So here we have the grid code applying. 172 00:09:11,230 --> 00:09:14,330 So the code from the grid class. 173 00:09:14,330 --> 00:09:17,900 So this one here, and then we have the grid 4-cols, 174 00:09:17,900 --> 00:09:19,090 of course. 175 00:09:19,090 --> 00:09:20,170 So this one here, 176 00:09:20,170 --> 00:09:23,250 which then makes it so that we have the four columns 177 00:09:23,250 --> 00:09:24,653 as we specified here. 178 00:09:26,270 --> 00:09:27,103 Right? 179 00:09:27,103 --> 00:09:29,200 And so this is a very nice technique 180 00:09:29,200 --> 00:09:31,740 to basically export these different styles 181 00:09:31,740 --> 00:09:34,140 into different classes in order to make them 182 00:09:34,140 --> 00:09:37,260 reusable across our page. 183 00:09:37,260 --> 00:09:39,730 Now another thing that we might want to reuse 184 00:09:39,730 --> 00:09:42,280 a couple of times over our page 185 00:09:42,280 --> 00:09:45,970 is a centered container element, right? 186 00:09:45,970 --> 00:09:48,350 So that's something that we have used a couple of times 187 00:09:48,350 --> 00:09:51,600 in past projects and actually already... 188 00:09:51,600 --> 00:09:54,330 also in our hero section. Right? 189 00:09:54,330 --> 00:09:56,800 And so let's actually also export that 190 00:09:56,800 --> 00:09:59,830 into its own class like this. 191 00:09:59,830 --> 00:10:02,323 So a generic container basically, 192 00:10:03,270 --> 00:10:04,670 let me do that here. 193 00:10:04,670 --> 00:10:05,503 And a bit later, 194 00:10:05,503 --> 00:10:09,200 I will then of course move all of this code here to the 195 00:10:09,200 --> 00:10:11,713 generic section in our CSS file here. 196 00:10:13,460 --> 00:10:16,840 But now let's create a container here. 197 00:10:16,840 --> 00:10:19,810 So this container is going to be the element that we're 198 00:10:19,810 --> 00:10:20,810 always going to use 199 00:10:20,810 --> 00:10:24,240 in order to center the content on our page. 200 00:10:24,240 --> 00:10:28,070 So inside of the browser viewport, right? 201 00:10:28,070 --> 00:10:31,400 So as always, we need to define a width here 202 00:10:31,400 --> 00:10:32,770 and we do that again, 203 00:10:32,770 --> 00:10:35,430 using the max width property 204 00:10:35,430 --> 00:10:37,450 to make it nice and fluid, 205 00:10:37,450 --> 00:10:41,440 and here I'm going to go with 120 REM. 206 00:10:41,440 --> 00:10:43,960 So that's basically 1200 pixels 207 00:10:43,960 --> 00:10:47,120 and that's kind of a standard we might say. 208 00:10:47,120 --> 00:10:49,780 So that's something that many pages use. 209 00:10:49,780 --> 00:10:53,470 Another one is 1140 pixels. 210 00:10:53,470 --> 00:10:57,260 So this is somehow also some kind of convention 211 00:10:57,260 --> 00:10:58,970 that you can also use. 212 00:10:58,970 --> 00:11:02,770 And that's actually very similar to this 1200 pixels, 213 00:11:02,770 --> 00:11:05,150 which I really like to use. 214 00:11:05,150 --> 00:11:07,050 So basically with this here, 215 00:11:07,050 --> 00:11:10,560 we are now defining that most of the content on our page, 216 00:11:10,560 --> 00:11:13,240 which will live inside our container of this 217 00:11:13,240 --> 00:11:16,680 will have this width here, or less. 218 00:11:16,680 --> 00:11:19,930 So when the viewport is less than 1200 pixels, 219 00:11:19,930 --> 00:11:24,033 then of course the container will shrink down, right? 220 00:11:25,370 --> 00:11:27,480 Then we can center it 221 00:11:27,480 --> 00:11:28,950 and also using margin 222 00:11:30,610 --> 00:11:32,490 set to zero and auto. 223 00:11:32,490 --> 00:11:34,490 And remember that this auto here, 224 00:11:34,490 --> 00:11:35,930 basically what it does 225 00:11:35,930 --> 00:11:39,600 is to give the same margin to the left and right side, 226 00:11:39,600 --> 00:11:42,370 and it will be figured out automatically. 227 00:11:42,370 --> 00:11:44,360 And so since these two margin values 228 00:11:44,360 --> 00:11:46,630 are the same on both sides, 229 00:11:46,630 --> 00:11:50,013 it basically makes the content look as if it was centered. 230 00:11:52,010 --> 00:11:55,420 Okay, and now we can apply this once again, 231 00:11:55,420 --> 00:11:56,663 for example here. 232 00:11:57,500 --> 00:12:00,350 Let's edit first, but the order doesn't matter of course. 233 00:12:01,730 --> 00:12:04,750 So now this element here is going to be a container 234 00:12:04,750 --> 00:12:07,310 and a grid, and a grid with two columns 235 00:12:07,310 --> 00:12:08,533 all at the same time. 236 00:12:10,730 --> 00:12:11,650 All right. 237 00:12:11,650 --> 00:12:13,070 And here you see it 238 00:12:14,850 --> 00:12:16,100 and let's shrink it down. 239 00:12:17,320 --> 00:12:19,450 So all the way to 1200 pixels. 240 00:12:19,450 --> 00:12:22,163 And then of course it is shrinking down. 241 00:12:23,330 --> 00:12:25,020 Here we still have those... 242 00:12:26,310 --> 00:12:28,760 Because they come from down here from these 243 00:12:28,760 --> 00:12:32,530 which are a bit too big to fit this viewport, 244 00:12:32,530 --> 00:12:35,840 but here actually it is happening what should be happening. 245 00:12:35,840 --> 00:12:39,820 So everything is nicely shrinking, right? 246 00:12:39,820 --> 00:12:41,480 Now here we just have that problem 247 00:12:41,480 --> 00:12:44,210 that the content is all the way glued 248 00:12:44,210 --> 00:12:46,430 here to the left and the right side. 249 00:12:46,430 --> 00:12:48,510 And so we should probably add some padding 250 00:12:48,510 --> 00:12:50,900 to our container element here, 251 00:12:50,900 --> 00:12:54,243 just like we did actually right here in the hero. 252 00:12:56,580 --> 00:13:01,580 So there, we added 3.2 pixels, 253 00:13:01,700 --> 00:13:02,983 or REM actually. 254 00:13:04,498 --> 00:13:07,533 And so let's do the exact same thing here. 255 00:13:09,940 --> 00:13:10,773 Okay. 256 00:13:14,300 --> 00:13:15,730 Right here. 257 00:13:15,730 --> 00:13:17,010 And by doing this, 258 00:13:17,010 --> 00:13:21,110 we will basically subtract 32 pixels from both sides 259 00:13:21,110 --> 00:13:22,310 of our content. 260 00:13:22,310 --> 00:13:25,440 And so in the end we will actually end up with something 261 00:13:25,440 --> 00:13:29,640 very similar of these 1140 pixels of width 262 00:13:29,640 --> 00:13:30,683 for the content. 263 00:13:31,680 --> 00:13:33,840 So that's because of the box model. 264 00:13:33,840 --> 00:13:35,640 So let me show you what I mean here. 265 00:13:39,230 --> 00:13:44,220 So yeah, so this is what I set. 266 00:13:44,220 --> 00:13:47,620 So we define this box to be 1200 pixels wide, 267 00:13:47,620 --> 00:13:49,520 but then as I just mentioned, 268 00:13:49,520 --> 00:13:53,160 we basically subtract 32 pixels on both sides. 269 00:13:53,160 --> 00:13:56,060 And then we end up with these 1,136, 270 00:13:56,060 --> 00:13:59,283 which is almost those 1,140 pixels. 271 00:14:01,610 --> 00:14:04,610 And so now when we do this, 272 00:14:04,610 --> 00:14:07,993 then the content is no longer glued to the sides. 273 00:14:10,230 --> 00:14:11,860 Okay? 274 00:14:11,860 --> 00:14:15,130 However, usually when we have a background color 275 00:14:15,130 --> 00:14:16,230 on the section, 276 00:14:16,230 --> 00:14:19,060 we do want the background color to extend 277 00:14:19,060 --> 00:14:20,693 all the way to the sides. 278 00:14:21,980 --> 00:14:24,623 So exactly what we had also up here. 279 00:14:26,410 --> 00:14:28,190 And when I say background color, 280 00:14:28,190 --> 00:14:29,840 then the same might also be true 281 00:14:29,840 --> 00:14:31,803 for some kind of background image. 282 00:14:32,970 --> 00:14:34,620 And so what we need to do 283 00:14:34,620 --> 00:14:39,300 is to actually not add all of this here to this element, 284 00:14:39,300 --> 00:14:41,040 so to the section itself, 285 00:14:41,040 --> 00:14:43,470 but instead wrap all of this into 286 00:14:43,470 --> 00:14:44,963 yet another div element. 287 00:14:47,230 --> 00:14:50,113 So this is the one with all these classes. 288 00:14:52,946 --> 00:14:56,030 So this one here is actually the container, the grid 289 00:14:56,030 --> 00:14:57,623 and the grid with two columns. 290 00:14:59,670 --> 00:15:02,003 Well, now something is strange here. 291 00:15:03,100 --> 00:15:05,133 So let's inspect this. 292 00:15:07,990 --> 00:15:08,823 Oh, of course. 293 00:15:08,823 --> 00:15:11,520 It's because these selectors 294 00:15:11,520 --> 00:15:13,670 that we did here with the nth child 295 00:15:13,670 --> 00:15:16,560 are no longer working as expected, 296 00:15:16,560 --> 00:15:17,900 because now this one here 297 00:15:17,900 --> 00:15:21,633 is actually the first child of this section. 298 00:15:23,480 --> 00:15:26,750 So this one here is now applying to the entire box, 299 00:15:26,750 --> 00:15:29,373 but well, that's not really a problem anyway. 300 00:15:30,340 --> 00:15:33,950 So let's just remove those tiles 301 00:15:33,950 --> 00:15:36,623 since we do no longer need them actually anyway. 302 00:15:40,620 --> 00:15:42,820 So we can maybe just leave this here. 303 00:15:42,820 --> 00:15:44,120 And so now we want 304 00:15:46,160 --> 00:15:50,230 the div that is a child of the div of the section how. 305 00:15:50,230 --> 00:15:52,493 So that will then select these four here. 306 00:15:55,100 --> 00:15:58,300 We just give them some other random background color. 307 00:16:01,800 --> 00:16:03,083 Well, maybe not orange. 308 00:16:04,910 --> 00:16:06,023 Yeah, just like this. 309 00:16:08,180 --> 00:16:10,930 Okay, and so now we can nicely see 310 00:16:10,930 --> 00:16:13,940 how the background color extends all the way 311 00:16:13,940 --> 00:16:16,603 from the right to the left side here, 312 00:16:17,670 --> 00:16:20,950 all while keeping this in a nice container 313 00:16:20,950 --> 00:16:22,483 that keeps being centered. 314 00:16:24,640 --> 00:16:27,340 And then again, once the viewport shrinks, 315 00:16:27,340 --> 00:16:30,403 we then get this nice space right here. 316 00:16:33,980 --> 00:16:35,510 So that works beautifully. 317 00:16:35,510 --> 00:16:37,203 This one we no longer need. 318 00:16:40,840 --> 00:16:42,810 Well, let's just keep them here for now, 319 00:16:42,810 --> 00:16:44,833 but we don't need them anymore as well. 320 00:16:45,680 --> 00:16:47,800 Sort of leading this style. 321 00:16:47,800 --> 00:16:50,870 And so these reusable classes, 322 00:16:50,870 --> 00:16:54,463 I will now put them up here. 323 00:16:57,240 --> 00:16:58,910 So in the reusables 324 00:17:00,050 --> 00:17:01,660 and right at the very top, 325 00:17:01,660 --> 00:17:04,730 because we're going to use these ones all the time 326 00:17:04,730 --> 00:17:07,580 as we build the rest of the page. 327 00:17:07,580 --> 00:17:10,000 Okay, now just one more thing, 328 00:17:10,000 --> 00:17:12,000 which is that you might be wondering 329 00:17:12,000 --> 00:17:14,820 why we did not use this sort of container 330 00:17:14,820 --> 00:17:16,633 in our hero section. 331 00:17:17,860 --> 00:17:20,580 Because we actually did something a bit similar. 332 00:17:20,580 --> 00:17:22,040 So we have this section here 333 00:17:22,040 --> 00:17:22,873 and then in there 334 00:17:22,873 --> 00:17:27,110 we have a container which is a grid with two columns. 335 00:17:27,110 --> 00:17:29,520 So in this case, that is called hero, 336 00:17:29,520 --> 00:17:32,133 but it is very similar if we take a look at it. 337 00:17:34,170 --> 00:17:37,760 So yeah, right here, 338 00:17:37,760 --> 00:17:38,960 it has the margin, 339 00:17:38,960 --> 00:17:40,590 It has also the padding, 340 00:17:40,590 --> 00:17:44,523 and we also declare it as a grid with two columns. 341 00:17:46,020 --> 00:17:47,610 However, the big difference here 342 00:17:47,610 --> 00:17:50,560 is that the hero has a larger width. 343 00:17:50,560 --> 00:17:54,180 So the container that we defined has the 120 REM, 344 00:17:54,180 --> 00:17:56,090 so 1200 pixels, 345 00:17:56,090 --> 00:17:58,860 and this one has 130 REM. 346 00:17:58,860 --> 00:18:00,700 So a 1300 pixels, 347 00:18:00,700 --> 00:18:04,150 which means that it is 100 pixels wider. 348 00:18:04,150 --> 00:18:07,150 And of course it wouldn't have to be like this. 349 00:18:07,150 --> 00:18:09,840 So we could have done the exact same width, 350 00:18:09,840 --> 00:18:12,420 but actually I like it visually better 351 00:18:12,420 --> 00:18:13,750 when the hero section 352 00:18:13,750 --> 00:18:17,350 is a little bit wider than the rest of the content. 353 00:18:17,350 --> 00:18:18,613 So let's check that out. 354 00:18:19,470 --> 00:18:22,460 And now it's not really so visible anymore 355 00:18:22,460 --> 00:18:24,950 because we took away the background colors, 356 00:18:24,950 --> 00:18:29,140 but you can still see that the container now starts here, 357 00:18:29,140 --> 00:18:32,050 but the hero section starts a little bit more 358 00:18:32,050 --> 00:18:33,143 here on the left. 359 00:18:34,686 --> 00:18:37,523 And so again, that's because this section is wider. 360 00:18:39,990 --> 00:18:41,720 So if it had the same width 361 00:18:43,580 --> 00:18:45,130 and we can simply do that here, 362 00:18:46,730 --> 00:18:50,693 then of course it would be nicely aligned with this one. 363 00:18:51,850 --> 00:18:53,953 So now this container starts here, 364 00:18:56,890 --> 00:18:59,103 so we can see by hovering over it. 365 00:19:00,959 --> 00:19:03,580 And then the other container now starts 366 00:19:03,580 --> 00:19:05,060 at the exact same thing. 367 00:19:05,060 --> 00:19:07,703 And again, that's because it has to same width. 368 00:19:10,120 --> 00:19:13,210 But then this hero image here shrinks 369 00:19:13,210 --> 00:19:16,560 a little bit because as it has less space, 370 00:19:16,560 --> 00:19:18,830 of course it needs to become smaller 371 00:19:18,830 --> 00:19:21,360 and so I personally like it 372 00:19:21,360 --> 00:19:22,453 when this bigger. 373 00:19:23,410 --> 00:19:27,470 also here we now moved to four lines for this content, 374 00:19:27,470 --> 00:19:31,830 which of course we could fix by make the text smaller. 375 00:19:31,830 --> 00:19:33,990 But yeah, I think that, 376 00:19:33,990 --> 00:19:35,580 especially on bigger screens, 377 00:19:35,580 --> 00:19:37,150 it looks better when this... 378 00:19:38,290 --> 00:19:41,063 while when this hero section is a little bit bigger, 379 00:19:41,920 --> 00:19:43,930 so I can just increase this 380 00:19:43,930 --> 00:19:45,570 and then you can see that 381 00:19:45,570 --> 00:19:47,680 this image here gets a lot bigger 382 00:19:47,680 --> 00:19:50,753 and we get more space here as this increases. 383 00:19:52,560 --> 00:19:55,210 So 130 and yeah, 384 00:19:55,210 --> 00:19:57,040 I think that looks better. 385 00:19:57,040 --> 00:20:00,190 But of course, if later you build your own layout 386 00:20:00,190 --> 00:20:02,620 and your own hero sections, 387 00:20:02,620 --> 00:20:05,210 and you have a different type of content, 388 00:20:05,210 --> 00:20:07,410 maybe you're building one of the headers 389 00:20:07,410 --> 00:20:09,790 that we built in the previous section, 390 00:20:09,790 --> 00:20:11,900 which simply had a background image 391 00:20:11,900 --> 00:20:13,530 and then some content 392 00:20:13,530 --> 00:20:15,920 then of course it might be perfectly fine 393 00:20:15,920 --> 00:20:19,300 to simply have the same width on the entire page. 394 00:20:19,300 --> 00:20:22,150 And then you could reuse that container element 395 00:20:22,150 --> 00:20:24,033 also for this situation here. 396 00:20:26,320 --> 00:20:28,370 So I hope that made sense. 397 00:20:28,370 --> 00:20:30,400 And it is the reason why basically 398 00:20:30,400 --> 00:20:33,470 we built a special section... 399 00:20:33,470 --> 00:20:36,020 so a special container here 400 00:20:36,020 --> 00:20:37,673 just for this section alone. 401 00:20:38,730 --> 00:20:41,350 So the hero is many times a little bit different 402 00:20:41,350 --> 00:20:42,780 and a bit special. 403 00:20:42,780 --> 00:20:45,590 And so it's not a big deal to here, 404 00:20:45,590 --> 00:20:47,510 not have the reusable code. 405 00:20:47,510 --> 00:20:49,040 But then from now on, 406 00:20:49,040 --> 00:20:51,780 we will use this grid that we've just set up 407 00:20:51,780 --> 00:20:53,713 in all the sections that follow. 408 00:20:55,395 --> 00:20:57,450 So I hope that made sense to you 409 00:20:57,450 --> 00:21:00,350 and that you understand the logic behind 410 00:21:00,350 --> 00:21:02,710 basically dividing the functionality 411 00:21:02,710 --> 00:21:05,360 into these different classes. 412 00:21:05,360 --> 00:21:08,490 So container grid, and this one here, 413 00:21:08,490 --> 00:21:10,740 and that you can incorporate this technique 414 00:21:10,740 --> 00:21:13,420 into your own coding in the future. 415 00:21:13,420 --> 00:21:15,260 And now what we're going to do next 416 00:21:15,260 --> 00:21:19,030 is to start building this, how it works section. 417 00:21:19,030 --> 00:21:21,043 So stay tuned for that one. 29207

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.