All language subtitles for 062 Placing and Spanning Grid Items.en_US

af Afrikaans Download
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese Download
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,580 --> 00:00:02,960 So until now, 2 00:00:02,960 --> 00:00:06,170 we have basically led CSS grid decide 3 00:00:06,170 --> 00:00:10,330 where to place our items in a completely automatic way 4 00:00:10,330 --> 00:00:13,980 simply following the source HTML code. 5 00:00:13,980 --> 00:00:18,190 However, sometimes it's important to manually place elements 6 00:00:18,190 --> 00:00:22,160 in a grid cell other than the predefined one, 7 00:00:22,160 --> 00:00:24,063 and so let's now learn how. 8 00:00:25,640 --> 00:00:28,760 And let's start by turning this one here off, 9 00:00:28,760 --> 00:00:30,763 set this year back to 1fr, 10 00:00:33,410 --> 00:00:37,983 and actually let's turn this height back on, 11 00:00:39,080 --> 00:00:42,580 so this makes it look a little bit better. 12 00:00:42,580 --> 00:00:44,870 And also here I will increase the gap 13 00:00:44,870 --> 00:00:47,630 because that will make it easier to visualize 14 00:00:47,630 --> 00:00:49,223 what we are going to do now. 15 00:00:50,060 --> 00:00:50,893 Okay. 16 00:00:50,893 --> 00:00:54,110 But now let's go to the topic of this video, 17 00:00:54,110 --> 00:00:58,270 which is about how to place a certain grid item 18 00:00:58,270 --> 00:01:02,200 like this one here say, into another grid cell, 19 00:01:02,200 --> 00:01:04,180 like here, for example. 20 00:01:04,180 --> 00:01:05,730 So into a grid cell, 21 00:01:05,730 --> 00:01:08,983 that was not its default one, all right? 22 00:01:10,270 --> 00:01:13,840 And going back to the terminology of grid cells 23 00:01:13,840 --> 00:01:15,320 and all that, 24 00:01:15,320 --> 00:01:19,730 let me actually show you the very helpful dev tools 25 00:01:19,730 --> 00:01:21,693 that we have for CSS grids. 26 00:01:22,600 --> 00:01:25,150 So here you can actually see many of the terms 27 00:01:25,150 --> 00:01:28,630 that I mentioned before in the theory lecture. 28 00:01:28,630 --> 00:01:31,890 So you have to number the grid lines 29 00:01:31,890 --> 00:01:33,870 like one, two, three, four, five, 30 00:01:33,870 --> 00:01:38,870 you have the gutters and you also can see the grid cells. 31 00:01:39,120 --> 00:01:43,343 Well let me turn one of them off like this one here. 32 00:01:46,610 --> 00:01:50,460 So to turn us on, we need to actually click this here. 33 00:01:50,460 --> 00:01:52,900 And so here you can see that basically, 34 00:01:52,900 --> 00:01:56,460 the intersection of these two grid lines here 35 00:01:56,460 --> 00:01:58,640 creates this cell. 36 00:01:58,640 --> 00:02:02,350 So right now, this cell does not have any grid item, 37 00:02:02,350 --> 00:02:04,940 and that is perfectly okay. 38 00:02:04,940 --> 00:02:07,400 Then here, you have to so-called gutters, 39 00:02:07,400 --> 00:02:09,793 which we can create with the gap, 40 00:02:10,740 --> 00:02:12,460 and yeah. 41 00:02:12,460 --> 00:02:13,770 So these are in the tracks, 42 00:02:13,770 --> 00:02:18,690 so they're all tracks entity for column tracks like this, 43 00:02:18,690 --> 00:02:19,630 right? 44 00:02:19,630 --> 00:02:23,027 But now we are actually interested in these numbered 45 00:02:23,027 --> 00:02:26,110 grid lines here because they will allow us 46 00:02:26,110 --> 00:02:29,453 to place any grid item wherever we want. 47 00:02:30,930 --> 00:02:32,480 So let me show you how, 48 00:02:32,480 --> 00:02:35,700 and for that, I'm leaving, it turned on here. 49 00:02:35,700 --> 00:02:37,370 So let's actually use that example 50 00:02:37,370 --> 00:02:38,780 I mentioned in the beginning. 51 00:02:38,780 --> 00:02:43,430 So placing this grid item here inside of this grid cell, 52 00:02:43,430 --> 00:02:45,773 so basically in this position here. 53 00:02:46,780 --> 00:02:48,700 So let's select it, 54 00:02:48,700 --> 00:02:50,533 it is element eight, 55 00:02:51,910 --> 00:02:55,523 so the class has this one, el--8, 56 00:02:57,150 --> 00:02:58,710 and we wanted placed here. 57 00:02:58,710 --> 00:03:00,890 And so that is column number two 58 00:03:00,890 --> 00:03:03,140 as the visible from this grid line 59 00:03:03,140 --> 00:03:07,493 and row number one as the visible from this grid line. 60 00:03:09,230 --> 00:03:12,570 So let's start actually with the column. 61 00:03:12,570 --> 00:03:17,073 So we can say grid-column, 62 00:03:17,925 --> 00:03:21,400 and then as I said, that's column number two, 63 00:03:21,400 --> 00:03:25,113 and then we can also specify the end basically. 64 00:03:27,170 --> 00:03:31,700 So we say that it should start at column number two 65 00:03:31,700 --> 00:03:34,530 and end at column number three, 66 00:03:34,530 --> 00:03:36,113 so right here. 67 00:03:37,110 --> 00:03:38,723 So if I save this now, 68 00:03:39,660 --> 00:03:41,830 then you see that it did actually move 69 00:03:41,830 --> 00:03:43,800 to the second column. 70 00:03:43,800 --> 00:03:46,820 Now this created then an additional row here, 71 00:03:46,820 --> 00:03:49,790 but let's fix that now by moving it here 72 00:03:49,790 --> 00:03:52,100 to row number one. 73 00:03:52,100 --> 00:03:55,193 So again, turning these on now, 74 00:03:58,600 --> 00:04:03,147 so now to grit row number one to two, right? 75 00:04:05,160 --> 00:04:07,860 And keep in mind that these two are properties 76 00:04:07,860 --> 00:04:12,410 that always need to be used on grid items, right? 77 00:04:12,410 --> 00:04:17,340 So this here, like grid template, columns, rows, and gap 78 00:04:17,340 --> 00:04:19,240 are used on the grid container 79 00:04:19,240 --> 00:04:21,893 while these are used on grid items. 80 00:04:22,950 --> 00:04:26,393 But anyway, let's put it here exactly where we want it, 81 00:04:27,240 --> 00:04:29,460 and there you go, 82 00:04:29,460 --> 00:04:33,960 now it is right here exactly where we placed it. 83 00:04:33,960 --> 00:04:37,170 And now let's do the same with this one here, 84 00:04:37,170 --> 00:04:39,593 and I want to place it down here. 85 00:04:40,830 --> 00:04:42,563 So let me select it first, 86 00:04:43,410 --> 00:04:45,530 so that's element two. 87 00:04:45,530 --> 00:04:48,360 And now I want you to pause the video 88 00:04:48,360 --> 00:04:51,300 and write the code to again, 89 00:04:51,300 --> 00:04:55,060 place this item exactly in this cell. 90 00:04:55,060 --> 00:04:57,250 So do you think you can do that? 91 00:04:57,250 --> 00:05:00,180 Hopefully you can, and I see you here in a minute, 92 00:05:00,180 --> 00:05:01,423 once you already. 93 00:05:03,110 --> 00:05:04,580 Okay. 94 00:05:04,580 --> 00:05:08,290 So let's once again, turn on the visualization here 95 00:05:09,130 --> 00:05:11,523 and then let's write our code. 96 00:05:12,480 --> 00:05:14,030 So that is grit column 97 00:05:17,230 --> 00:05:21,050 one to two, right? 98 00:05:21,050 --> 00:05:24,380 So it should start here and go here. 99 00:05:24,380 --> 00:05:28,463 And then as for the row, it should go two to three. 100 00:05:29,750 --> 00:05:33,113 So grid-row two to three. 101 00:05:36,050 --> 00:05:39,203 And there it is, beautiful. 102 00:05:40,090 --> 00:05:42,990 And actually if the second value here 103 00:05:42,990 --> 00:05:47,250 is just one more than the first, we can omit it. 104 00:05:47,250 --> 00:05:48,523 So we can do this, 105 00:05:49,980 --> 00:05:52,940 and it will still be in the same place. 106 00:05:52,940 --> 00:05:55,160 However, what do you think will happen 107 00:05:55,160 --> 00:05:57,530 when we specify a second value 108 00:05:57,530 --> 00:05:59,723 that is actually not just plus one? 109 00:06:00,760 --> 00:06:05,690 So we had this, but what if we did this? 110 00:06:05,690 --> 00:06:09,030 So what do you think it is going to look like now? 111 00:06:09,030 --> 00:06:10,810 So let's save that, 112 00:06:10,810 --> 00:06:15,810 and well, now this item spans across two cells. 113 00:06:17,620 --> 00:06:19,810 So let's again, bring back, 114 00:06:19,810 --> 00:06:23,860 and so yeah, this is exactly what we specified. 115 00:06:23,860 --> 00:06:26,760 So column one to three, 116 00:06:26,760 --> 00:06:31,180 and so therefore now it fills these two cells here. 117 00:06:31,180 --> 00:06:33,350 And so this is the trick that we use 118 00:06:33,350 --> 00:06:38,150 in order to have an item span across multiple grid cells. 119 00:06:38,150 --> 00:06:41,940 And of course, we could use any other number here, 120 00:06:41,940 --> 00:06:44,450 like four, right? 121 00:06:44,450 --> 00:06:47,900 And so now it spans across these three cells. 122 00:06:47,900 --> 00:06:51,920 And notice how I just said three cells, right? 123 00:06:51,920 --> 00:06:56,340 So sometimes we might not want to do math here, 124 00:06:56,340 --> 00:07:01,340 and so instead of this, we can actually also say span three. 125 00:07:02,060 --> 00:07:06,340 So in other words, instead of specifying the final value 126 00:07:06,340 --> 00:07:09,190 of the grid line, we can simply say, 127 00:07:09,190 --> 00:07:13,800 start at one and then span across three cells. 128 00:07:13,800 --> 00:07:18,160 And so this should not look exactly the same, and it does. 129 00:07:18,160 --> 00:07:21,750 So let me keep that other one here as well, 130 00:07:21,750 --> 00:07:24,083 so as a reference basically. 131 00:07:25,230 --> 00:07:27,303 But these two are exactly the same. 132 00:07:28,500 --> 00:07:29,380 All right. 133 00:07:29,380 --> 00:07:31,853 And if we say span 2, well then, 134 00:07:32,750 --> 00:07:37,130 as you can expect, it will only span across two cells 135 00:07:37,130 --> 00:07:40,750 and then like this, which is quite unnecessary, 136 00:07:40,750 --> 00:07:42,450 but just to see it, 137 00:07:42,450 --> 00:07:45,333 now we are back to filling only one cell. 138 00:07:46,640 --> 00:07:49,680 Now of course, we can also say span 4, 139 00:07:49,680 --> 00:07:52,160 and then it will go all the way from one side 140 00:07:52,160 --> 00:07:55,120 to the container of the other one. 141 00:07:55,120 --> 00:07:58,020 And let's actually keep working with this situation 142 00:07:58,020 --> 00:08:00,230 where we want one grid item 143 00:08:00,230 --> 00:08:04,090 to span all the way to the end of the container. 144 00:08:04,090 --> 00:08:07,050 So in some situations, we might not even know 145 00:08:07,050 --> 00:08:09,850 how many columns there are in a grid, 146 00:08:09,850 --> 00:08:12,510 or we might simply not want to think about 147 00:08:12,510 --> 00:08:15,190 how many cells we need to span. 148 00:08:15,190 --> 00:08:16,690 And so in those situations, 149 00:08:16,690 --> 00:08:19,600 there is a very nice trick that we can use 150 00:08:19,600 --> 00:08:21,423 instead of manually spanning. 151 00:08:22,720 --> 00:08:25,330 So let me again, just copy this 152 00:08:25,330 --> 00:08:28,503 and turning it off to keep it as a reference, 153 00:08:30,090 --> 00:08:31,300 all right? 154 00:08:31,300 --> 00:08:33,630 And so if we simply want one element 155 00:08:33,630 --> 00:08:35,830 to span all the way to the end, 156 00:08:35,830 --> 00:08:37,773 we can use minus one, 157 00:08:38,860 --> 00:08:41,583 so you see the result is the same. 158 00:08:43,410 --> 00:08:45,010 And it still works of course, 159 00:08:45,010 --> 00:08:47,770 for example, if we started this at two, 160 00:08:47,770 --> 00:08:50,860 so then it would start at two and it would span 161 00:08:50,860 --> 00:08:53,663 all the way to the end, which is minus one. 162 00:08:55,030 --> 00:08:58,633 And now let me quickly show you why this trick works, 163 00:08:59,660 --> 00:09:02,960 which is actually a really great trick, 164 00:09:02,960 --> 00:09:04,243 a really great idea. 165 00:09:05,210 --> 00:09:08,940 So you see that these grid lines go from one, two, three 166 00:09:08,940 --> 00:09:12,230 to five here at the top of the grid. 167 00:09:12,230 --> 00:09:15,600 However, at the bottom of the grit if you see, 168 00:09:15,600 --> 00:09:19,680 then they go from minus one to minus five, 169 00:09:19,680 --> 00:09:21,853 so basically in the opposite direction. 170 00:09:22,890 --> 00:09:26,210 So what this means is that each of these grid lines 171 00:09:26,210 --> 00:09:27,960 actually has two numbers. 172 00:09:27,960 --> 00:09:30,020 So this one is not only four, 173 00:09:30,020 --> 00:09:32,690 but also minus two. 174 00:09:32,690 --> 00:09:34,810 And so this one, which is the last one 175 00:09:34,810 --> 00:09:39,630 is not only five, but it is also minus one, 176 00:09:39,630 --> 00:09:42,400 and so this is why the trick works. 177 00:09:42,400 --> 00:09:45,190 So we start at one, which is here, 178 00:09:45,190 --> 00:09:48,590 so this grid line is called one and minus five, 179 00:09:48,590 --> 00:09:52,600 and so we can just use this one, so one, 180 00:09:52,600 --> 00:09:55,270 and then, we go all the way to minus one, 181 00:09:55,270 --> 00:09:58,250 which again is this last one here. 182 00:09:58,250 --> 00:10:01,600 And so this is why this trick works. 183 00:10:01,600 --> 00:10:05,730 Okay, and finally, of course the same thing, 184 00:10:05,730 --> 00:10:09,390 so spanning also works for rows. 185 00:10:09,390 --> 00:10:14,390 So let's experiment maybe with this number six here now. 186 00:10:15,560 --> 00:10:17,743 So el--6, 187 00:10:18,850 --> 00:10:22,230 and let's leave the column where it is. 188 00:10:22,230 --> 00:10:26,770 So of course we can, if we want only manipulate one of them. 189 00:10:26,770 --> 00:10:29,943 And so let's say grid-row, 190 00:10:31,620 --> 00:10:33,563 so right now, it is at three, 191 00:10:34,560 --> 00:10:37,563 but let's say we want it to go until six. 192 00:10:39,860 --> 00:10:42,750 Well, that's not what I intended, 193 00:10:42,750 --> 00:10:45,673 so I think I said three, not four. 194 00:10:47,400 --> 00:10:50,233 So yeah, this is what I was looking for. 195 00:10:51,550 --> 00:10:54,860 So this doesn't look very special, 196 00:10:54,860 --> 00:10:57,820 but actually what happened was that a new row here 197 00:10:57,820 --> 00:10:59,630 was inserted. 198 00:10:59,630 --> 00:11:01,713 Let's just do this until four, 199 00:11:03,660 --> 00:11:04,970 okay? 200 00:11:04,970 --> 00:11:07,990 So now you see that a new row was inserted. 201 00:11:07,990 --> 00:11:10,640 So a three, then here for some reason, 202 00:11:10,640 --> 00:11:11,900 we're missing the four, 203 00:11:11,900 --> 00:11:15,390 but then there is five all the way at the end. 204 00:11:15,390 --> 00:11:18,850 So this is maybe not such a good example, 205 00:11:18,850 --> 00:11:23,850 but we can just experiment a little bit more with this. 206 00:11:24,050 --> 00:11:27,253 So if we just briefly turn off this one here, 207 00:11:28,123 --> 00:11:30,750 then we have some more space 208 00:11:30,750 --> 00:11:34,030 so that we can span this one here. 209 00:11:34,030 --> 00:11:36,840 So this number eight, we already have it selected, 210 00:11:36,840 --> 00:11:41,090 and so if we say, for example, three here, 211 00:11:41,090 --> 00:11:45,970 then as expected, it will span these two grid cells now 212 00:11:45,970 --> 00:11:48,070 across these two rows. 213 00:11:48,070 --> 00:11:50,660 And the same works if we say minus one, 214 00:11:50,660 --> 00:11:53,000 then it goes all the way to the end, 215 00:11:53,000 --> 00:11:55,923 or if we say span two. 216 00:11:56,890 --> 00:11:58,430 If we said span three, 217 00:11:58,430 --> 00:12:02,460 then it would create just another row down here, 218 00:12:02,460 --> 00:12:07,203 so just like we saw it actually happening before, okay? 219 00:12:09,070 --> 00:12:11,533 But let's actually turn it off again. 220 00:12:14,580 --> 00:12:16,953 I will again just leave it here as a reference. 221 00:12:18,580 --> 00:12:19,960 Let's turn this one back on 222 00:12:19,960 --> 00:12:24,110 because I liked the way that looked, and yeah. 223 00:12:24,110 --> 00:12:27,250 So I think I showed you enough now about this topic, 224 00:12:27,250 --> 00:12:30,400 but this is worth experimenting a lot with. 225 00:12:30,400 --> 00:12:34,630 So I hope that you have some time to maybe do that now. 226 00:12:34,630 --> 00:12:37,407 So you can select different elements here 227 00:12:37,407 --> 00:12:39,070 and then see what happens 228 00:12:39,070 --> 00:12:41,800 when you place them in different cells 229 00:12:41,800 --> 00:12:43,590 and do some spanning, 230 00:12:43,590 --> 00:12:46,260 and you can even try to overlap them. 231 00:12:46,260 --> 00:12:50,110 So basically placing different grid items in the same cell, 232 00:12:50,110 --> 00:12:52,950 and you will see that that actually works. 233 00:12:52,950 --> 00:12:54,560 So have some fun with that, 234 00:12:54,560 --> 00:12:57,723 and then I will see you back here for our next lecture. 16961

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