All language subtitles for 089 Building an Accordion Component - Part 2.en_US

af Afrikaans
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
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,550 --> 00:00:04,910 So now it's time to actually build the layout 2 00:00:04,910 --> 00:00:06,423 of our accordion. 3 00:00:07,700 --> 00:00:09,980 And so basically what we want to do 4 00:00:09,980 --> 00:00:13,260 is to style this item element here, 5 00:00:13,260 --> 00:00:16,523 so all of this to have some nice layout. 6 00:00:18,040 --> 00:00:21,613 So it's this one here, right? 7 00:00:22,510 --> 00:00:26,490 Basically because each of the items of the accordion 8 00:00:26,490 --> 00:00:28,893 are called like this, so item. 9 00:00:29,890 --> 00:00:31,970 Let's see what we have here, 10 00:00:31,970 --> 00:00:33,240 and so first of all, 11 00:00:33,240 --> 00:00:37,230 there is like a shadow around that item, 12 00:00:37,230 --> 00:00:40,670 and then there is of course also some whitespace 13 00:00:40,670 --> 00:00:43,700 inside of it, so some padding. 14 00:00:43,700 --> 00:00:46,360 And finally, there is this green line on top, 15 00:00:46,360 --> 00:00:48,503 but we will take care of that later. 16 00:00:49,680 --> 00:00:52,713 So that will make a bit more sense once we get there. 17 00:00:54,410 --> 00:00:57,230 But now about the item, actually, 18 00:00:57,230 --> 00:01:00,233 so let's start with the box shadow here. 19 00:01:01,160 --> 00:01:05,610 So the first value remember is the horizontal offset, 20 00:01:05,610 --> 00:01:07,590 the second is vertical offset, 21 00:01:07,590 --> 00:01:10,700 and I'm simply setting both to zero here, 22 00:01:10,700 --> 00:01:12,400 and I'm doing it like this 23 00:01:12,400 --> 00:01:16,420 because basically I tried to replicate the accordion 24 00:01:16,420 --> 00:01:18,320 that I showed you in the last lecture, 25 00:01:19,160 --> 00:01:19,993 okay? 26 00:01:19,993 --> 00:01:23,240 Then the second one or the third value actually 27 00:01:23,240 --> 00:01:25,560 is a blur, 28 00:01:25,560 --> 00:01:29,180 then the fourth value I usually simply ignore it 29 00:01:29,180 --> 00:01:32,490 and go straight to the rgba. 30 00:01:32,490 --> 00:01:36,100 So black, which we know is zero in everything, 31 00:01:36,100 --> 00:01:39,630 and then the alpha, let's set it 2.1, 32 00:01:41,290 --> 00:01:44,450 and give it a save, 33 00:01:44,450 --> 00:01:45,980 and there we go. 34 00:01:45,980 --> 00:01:50,010 So a nice shadow here, basically around the entire element, 35 00:01:50,010 --> 00:01:53,060 and that's because here we didn't specify anything. 36 00:01:53,060 --> 00:01:55,750 If he put it here like this, 37 00:01:55,750 --> 00:01:59,760 then that whole shadow would move down, right? 38 00:01:59,760 --> 00:02:02,620 But again, I was just trying to basically copy 39 00:02:02,620 --> 00:02:05,603 that other design that this one is based on. 40 00:02:06,810 --> 00:02:08,910 Now let's add some padding here, 41 00:02:08,910 --> 00:02:12,180 and as always, I'm using old spacing system, 42 00:02:12,180 --> 00:02:14,460 but I'm not going up and down all the time 43 00:02:14,460 --> 00:02:16,360 to test these values, 44 00:02:16,360 --> 00:02:19,373 so I've already experimented with that before. 45 00:02:20,730 --> 00:02:23,000 So 24 pixels here, 46 00:02:23,000 --> 00:02:26,240 and now it's time to think about the layout. 47 00:02:26,240 --> 00:02:27,873 So let's quickly go back, 48 00:02:28,930 --> 00:02:31,040 so what do we have here? 49 00:02:31,040 --> 00:02:34,760 We basically have these four elements again, 50 00:02:34,760 --> 00:02:36,340 and as we can see, 51 00:02:36,340 --> 00:02:40,570 they are kind of in a two dimensional grid, right? 52 00:02:40,570 --> 00:02:43,100 So we have some here in this first line 53 00:02:43,100 --> 00:02:45,820 and then this box here is in the second line. 54 00:02:45,820 --> 00:02:48,700 So what that means is that we should probably use 55 00:02:48,700 --> 00:02:51,653 CSS Grid for this, right? 56 00:02:52,500 --> 00:02:57,480 So one column right here, second column and third column, 57 00:02:57,480 --> 00:02:59,140 okay? 58 00:02:59,140 --> 00:03:00,253 So let's do that. 59 00:03:03,000 --> 00:03:07,130 So display grid, remember? 60 00:03:07,130 --> 00:03:09,740 And then we need to define all columns, 61 00:03:09,740 --> 00:03:13,770 and remember that for that, we use the grid template 62 00:03:17,060 --> 00:03:18,253 columns property. 63 00:03:19,190 --> 00:03:22,090 And now here, we simply need to define the width 64 00:03:22,090 --> 00:03:24,420 of all our three columns. 65 00:03:24,420 --> 00:03:26,730 So what numbers do you think I should use 66 00:03:26,730 --> 00:03:28,480 for the three columns? 67 00:03:28,480 --> 00:03:31,100 Can you think about that for a little bit? 68 00:03:31,100 --> 00:03:33,700 Well, the first one should simply be the width 69 00:03:33,700 --> 00:03:36,450 of the content, right? 70 00:03:36,450 --> 00:03:40,300 So if the content is 02, then that should be the width, 71 00:03:40,300 --> 00:03:43,080 but if it was like 027, 72 00:03:43,080 --> 00:03:45,790 then the column should be wider. 73 00:03:45,790 --> 00:03:49,360 And so what that means is that we want the column 74 00:03:49,360 --> 00:03:51,800 to basically have an automatic width, 75 00:03:51,800 --> 00:03:54,080 so based on the content. 76 00:03:54,080 --> 00:03:56,880 Then the same is true for the last one here, 77 00:03:56,880 --> 00:03:58,480 so let's write that immediately. 78 00:03:59,540 --> 00:04:02,910 And then finally, the second column, the one in the middle 79 00:04:02,910 --> 00:04:06,450 should very simply occupy all the remaining space. 80 00:04:06,450 --> 00:04:08,130 And so remember that for that, 81 00:04:08,130 --> 00:04:11,370 we can use auto fr unit, 82 00:04:11,370 --> 00:04:12,373 so 1fr. 83 00:04:13,390 --> 00:04:15,920 And with this, actually our layout 84 00:04:15,920 --> 00:04:18,793 should basically be almost finished already. 85 00:04:19,740 --> 00:04:24,480 Okay, and that looks almost correct, all right? 86 00:04:24,480 --> 00:04:26,780 So we do have three columns. 87 00:04:26,780 --> 00:04:30,160 However, that first column is way wider than we thought 88 00:04:30,160 --> 00:04:31,240 it should be. 89 00:04:31,240 --> 00:04:34,910 And the reason for that, and let's inspect this here, 90 00:04:34,910 --> 00:04:38,830 is that of course, this fourth element, 91 00:04:38,830 --> 00:04:42,930 so the hidden box of course goes here into the second row 92 00:04:42,930 --> 00:04:47,490 into the very first column, right? 93 00:04:47,490 --> 00:04:50,500 So that's only natural because that is the automatic 94 00:04:50,500 --> 00:04:54,720 placement of the grid items inside of the grid. 95 00:04:54,720 --> 00:04:58,560 However, we do not want this element here, right? 96 00:04:58,560 --> 00:05:02,510 Instead, we want it nicely aligned with the title. 97 00:05:02,510 --> 00:05:05,220 And so there's this actually one of the huge advantages 98 00:05:05,220 --> 00:05:08,540 of using CSS Grid here in the first place, 99 00:05:08,540 --> 00:05:12,530 because by now placing this box inside of this cell, 100 00:05:12,530 --> 00:05:17,230 that will very easily align this content with this title, 101 00:05:17,230 --> 00:05:18,500 right? 102 00:05:18,500 --> 00:05:22,270 So let's define that here in our hidden box. 103 00:05:22,270 --> 00:05:24,960 And do you remember how that works? 104 00:05:24,960 --> 00:05:29,960 Well, we can simply say grid column, 105 00:05:30,565 --> 00:05:33,843 and then we say that we wanted in column number two. 106 00:05:34,890 --> 00:05:37,710 So that's because of these grid lines here, 107 00:05:37,710 --> 00:05:40,250 so grid line one and two. 108 00:05:40,250 --> 00:05:43,113 And so now it will start here in grid line number two. 109 00:05:44,220 --> 00:05:48,363 So with a nice save, now it looks correct. 110 00:05:49,220 --> 00:05:50,130 Great. 111 00:05:50,130 --> 00:05:53,860 Now all we have to fix is of course the spacing here, 112 00:05:53,860 --> 00:05:58,463 but besides that, it is actually almost done already. 113 00:05:59,910 --> 00:06:02,400 So let's give it a column gap 114 00:06:03,850 --> 00:06:07,583 of, let's say 24 pixels, 115 00:06:09,090 --> 00:06:10,180 okay? 116 00:06:10,180 --> 00:06:11,500 And I'm using different gaps 117 00:06:11,500 --> 00:06:15,610 because I want there to be a lot more gap in the row 118 00:06:15,610 --> 00:06:17,430 or at least some more, 119 00:06:17,430 --> 00:06:22,410 so let's say 32 pixels, okay? 120 00:06:22,410 --> 00:06:23,243 Beautiful. 121 00:06:24,300 --> 00:06:27,753 So now it does look almost like this one here. 122 00:06:29,460 --> 00:06:31,760 Now just one thing is that we should align 123 00:06:31,760 --> 00:06:34,863 all of these elements here, like vertically, 124 00:06:35,840 --> 00:06:38,720 because right now I think it's not. 125 00:06:38,720 --> 00:06:41,423 So this one looks off a little bit, 126 00:06:42,490 --> 00:06:44,560 but that is quite easy. 127 00:06:44,560 --> 00:06:47,820 So we want to align the grid items themselves 128 00:06:47,820 --> 00:06:49,750 inside of the cells, 129 00:06:49,750 --> 00:06:53,823 and so for that, we need one of the align properties. 130 00:06:55,340 --> 00:06:58,940 And so since it's vertically, it is align items, 131 00:06:58,940 --> 00:07:02,683 set to center and let's see if something changes here. 132 00:07:03,860 --> 00:07:06,153 Well, not really, I think, 133 00:07:07,420 --> 00:07:10,380 but, well, anyway, it's still good to have this here 134 00:07:10,380 --> 00:07:11,920 like this. 135 00:07:11,920 --> 00:07:14,380 Now the content is also a bit too long, 136 00:07:14,380 --> 00:07:17,020 so let's cut some of it out 137 00:07:18,070 --> 00:07:20,243 like this last sentence here maybe, 138 00:07:21,790 --> 00:07:22,623 then, 139 00:07:26,240 --> 00:07:28,540 let's cut these two words, 140 00:07:28,540 --> 00:07:32,930 then here let's start or stop after a lamborum 141 00:07:32,930 --> 00:07:35,360 or whatever that is, and to here maybe 142 00:07:35,360 --> 00:07:36,883 that last word as well. 143 00:07:38,410 --> 00:07:39,850 Nice. 144 00:07:39,850 --> 00:07:40,683 Okay. 145 00:07:40,683 --> 00:07:44,180 And so now it's time to actually copy our code, 146 00:07:44,180 --> 00:07:47,920 and in order to add this one and this one here. 147 00:07:47,920 --> 00:07:49,933 So number one and number three. 148 00:07:50,950 --> 00:07:55,950 And so here in VS Code, we can do another nice trick, 149 00:07:56,040 --> 00:07:57,670 which is on this element here, 150 00:07:57,670 --> 00:08:01,290 we can click on the right side here on this small icon, 151 00:08:01,290 --> 00:08:03,543 and that will then collapse this completely. 152 00:08:04,380 --> 00:08:06,750 So you see now it goes from line number one 153 00:08:06,750 --> 00:08:09,110 immediately to 125. 154 00:08:09,110 --> 00:08:11,370 So basically all the content was hidden 155 00:08:11,370 --> 00:08:14,020 because now we can copy this very easily 156 00:08:14,020 --> 00:08:16,533 without having to scroll up and down. 157 00:08:17,690 --> 00:08:19,253 So we can just paste that here, 158 00:08:21,360 --> 00:08:25,143 so of course that is then open and I can paste it here. 159 00:08:26,740 --> 00:08:29,143 So this is supposed to be the number one, 160 00:08:30,400 --> 00:08:31,363 enter text, 161 00:08:32,840 --> 00:08:37,637 where are these chairs assembled? 162 00:08:40,460 --> 00:08:41,293 And, 163 00:08:42,600 --> 00:08:44,453 oh, actually that was wrong. 164 00:08:46,910 --> 00:08:48,093 Or actually it wasn't, 165 00:08:49,240 --> 00:08:51,940 I simply forgot that this one was still collapsed, 166 00:08:51,940 --> 00:08:53,110 number two. 167 00:08:53,110 --> 00:08:55,853 So this is 03, which is, 168 00:08:58,490 --> 00:09:03,490 do you ship to countries outside the EU? 169 00:09:09,650 --> 00:09:10,603 Okay. 170 00:09:11,770 --> 00:09:14,810 So that looks quite nice, 171 00:09:14,810 --> 00:09:17,130 but still not where we want it to be. 172 00:09:17,130 --> 00:09:19,010 And so now it's time, well, 173 00:09:19,010 --> 00:09:21,033 first to fix this spacing here, 174 00:09:22,490 --> 00:09:25,410 and where is that defined? 175 00:09:25,410 --> 00:09:27,583 Let's go back right here. 176 00:09:29,840 --> 00:09:32,713 Or actually whenever we have a bug like this, 177 00:09:32,713 --> 00:09:36,180 we just simply go ahead and inspect it. 178 00:09:36,180 --> 00:09:39,320 And I can immediately see the mistake that I made, 179 00:09:39,320 --> 00:09:42,230 which was to copy the entire accordion 180 00:09:42,230 --> 00:09:44,210 and not simply the item. 181 00:09:44,210 --> 00:09:46,693 So that was a stupid mistake, 182 00:09:48,030 --> 00:09:49,483 but that happens. 183 00:09:50,920 --> 00:09:53,970 So that's called delete this accordion 184 00:09:53,970 --> 00:09:56,473 and this closing tag from the previous one. 185 00:09:58,419 --> 00:09:59,550 Okay. 186 00:09:59,550 --> 00:10:01,170 And here the same thing, 187 00:10:01,170 --> 00:10:03,520 and now that should be fixed. 188 00:10:03,520 --> 00:10:06,780 So now they're actually glued to one another, 189 00:10:06,780 --> 00:10:09,140 so we need to fix that as well. 190 00:10:09,140 --> 00:10:11,600 And so now I will actually use that trick again, 191 00:10:11,600 --> 00:10:15,000 where I set the flex direction to column. 192 00:10:15,000 --> 00:10:18,333 So right here in the accordion, let's do that, 193 00:10:19,210 --> 00:10:23,710 because otherwise, I would have to now go into here 194 00:10:23,710 --> 00:10:26,120 and set a margin bottom to each of them 195 00:10:26,120 --> 00:10:29,360 and select the last one and take it away. 196 00:10:29,360 --> 00:10:32,150 But once again, I find that it's much easier 197 00:10:32,150 --> 00:10:35,590 to define these properties for example, 198 00:10:35,590 --> 00:10:39,023 related to a spacing right in the container element. 199 00:10:41,050 --> 00:10:42,283 So display flex, 200 00:10:43,770 --> 00:10:45,690 which again, by default, 201 00:10:45,690 --> 00:10:49,400 will put them side by side in this weird way, 202 00:10:49,400 --> 00:10:53,433 but then, we can easily say flex direction 203 00:10:55,270 --> 00:10:58,630 and set it to column, okay? 204 00:10:58,630 --> 00:10:59,750 Beautiful. 205 00:10:59,750 --> 00:11:02,150 So now we are where we started, 206 00:11:02,150 --> 00:11:04,870 and so now it's time to add that gap, 207 00:11:04,870 --> 00:11:07,860 which remember, will now be set vertically. 208 00:11:07,860 --> 00:11:09,690 And so that is actually the whole point 209 00:11:09,690 --> 00:11:13,873 of using flex direction set to column in this case. 210 00:11:14,750 --> 00:11:16,693 And so, nice. 211 00:11:17,710 --> 00:11:19,340 That's really cool. 212 00:11:19,340 --> 00:11:24,080 But now we actually want to basically hide this, 213 00:11:24,080 --> 00:11:27,750 hidden box here and this one in element number one 214 00:11:27,750 --> 00:11:29,470 and three. 215 00:11:29,470 --> 00:11:32,130 So how are we going to do that? 216 00:11:32,130 --> 00:11:34,830 Well, we will use a very common trick 217 00:11:34,830 --> 00:11:37,150 that we use in CSS all the time, 218 00:11:37,150 --> 00:11:39,840 especially when we create these components 219 00:11:39,840 --> 00:11:41,030 that will at some point 220 00:11:41,030 --> 00:11:43,760 have to work together with JavaScript. 221 00:11:43,760 --> 00:11:46,130 So basically we will by default 222 00:11:46,130 --> 00:11:50,760 set these three elements here to the default closed state, 223 00:11:50,760 --> 00:11:52,040 so to this one, 224 00:11:52,040 --> 00:11:54,830 where this text is gray and this is black, 225 00:11:54,830 --> 00:11:58,990 and there is also a no border at the top, 226 00:11:58,990 --> 00:12:01,150 and of course the content is hidden. 227 00:12:01,150 --> 00:12:03,620 And then, we will add a special class 228 00:12:03,620 --> 00:12:05,670 to this item right here, 229 00:12:05,670 --> 00:12:07,750 in this case, the item number two, 230 00:12:07,750 --> 00:12:10,450 which will then make it so that all the styles 231 00:12:10,450 --> 00:12:12,220 will be put back, 232 00:12:12,220 --> 00:12:16,780 so the green text and the border, all right? 233 00:12:16,780 --> 00:12:20,120 so that probably sounds more complicated 234 00:12:20,120 --> 00:12:21,343 than it actually is. 235 00:12:22,530 --> 00:12:25,950 So let's see how it works. 236 00:12:25,950 --> 00:12:27,690 So by default, remember, 237 00:12:27,690 --> 00:12:30,950 we will make the hidden box actually hidden. 238 00:12:30,950 --> 00:12:33,460 And for that, there are many, many ways 239 00:12:33,460 --> 00:12:35,983 in which we can hide elements in CSS, 240 00:12:37,120 --> 00:12:38,870 but more about that later, 241 00:12:38,870 --> 00:12:41,460 because for now we will just use the easiest way, 242 00:12:41,460 --> 00:12:44,270 which is display none, 243 00:12:44,270 --> 00:12:46,650 like this, all right? 244 00:12:46,650 --> 00:12:48,303 And so now they're all gone, 245 00:12:49,300 --> 00:12:53,570 then I want this text here also to be gone, 246 00:12:53,570 --> 00:12:55,540 so back to default, 247 00:12:55,540 --> 00:12:59,160 and also this number here should actually have 248 00:12:59,160 --> 00:13:02,770 a light gray color, 249 00:13:02,770 --> 00:13:04,803 so let me select that separately. 250 00:13:07,320 --> 00:13:08,530 And then let's once again, 251 00:13:08,530 --> 00:13:12,530 get that color actually here from open color, 252 00:13:12,530 --> 00:13:14,530 and now let's use this one. 253 00:13:14,530 --> 00:13:17,853 So this color will probably not really be accessible, 254 00:13:19,780 --> 00:13:24,780 but that's also a rule that sometimes we can break. 255 00:13:24,820 --> 00:13:27,910 So this number is not absolutely essential here 256 00:13:27,910 --> 00:13:30,630 for the user to understand this content, 257 00:13:30,630 --> 00:13:34,463 and so I think we are fine like this, okay? 258 00:13:35,740 --> 00:13:36,573 All right. 259 00:13:36,573 --> 00:13:40,090 So this is the default state basically. 260 00:13:40,090 --> 00:13:41,930 And so now, as I was saying, 261 00:13:41,930 --> 00:13:45,357 what we will do is to basically add a class to the element 262 00:13:45,357 --> 00:13:47,890 that we want to be open, 263 00:13:47,890 --> 00:13:52,140 so the one that we want to look as if it was open. 264 00:13:52,140 --> 00:13:55,610 And so that is the second one, so this one right here. 265 00:13:55,610 --> 00:14:00,610 So let's add a class of open, okay? 266 00:14:00,660 --> 00:14:03,110 And so now we can create some styles 267 00:14:03,110 --> 00:14:07,490 for the number and text that are inside of the element 268 00:14:07,490 --> 00:14:11,320 that is the open element, right? 269 00:14:11,320 --> 00:14:16,320 So that sounds probably confusing, but we can do it. 270 00:14:17,650 --> 00:14:21,420 So I will select the open element now, 271 00:14:21,420 --> 00:14:23,350 and the first thing that I'm going to do 272 00:14:23,350 --> 00:14:24,893 is to add that border, 273 00:14:27,590 --> 00:14:30,480 because that will be basically the easiest change 274 00:14:30,480 --> 00:14:32,100 that we want. 275 00:14:32,100 --> 00:14:34,890 So let's say four pixel solid 276 00:14:36,250 --> 00:14:38,490 and now our green color, 277 00:14:38,490 --> 00:14:39,410 all right? 278 00:14:39,410 --> 00:14:43,720 And so now the open box already has the green border. 279 00:14:43,720 --> 00:14:46,603 So just like this, right? 280 00:14:47,720 --> 00:14:50,720 But now let's also make this text green, 281 00:14:50,720 --> 00:14:54,230 and let's display that hidden box. 282 00:14:54,230 --> 00:14:56,370 So how can we do that? 283 00:14:56,370 --> 00:14:59,000 Well, we can do this, 284 00:14:59,000 --> 00:15:03,120 we say that basically the hidden box, 285 00:15:03,120 --> 00:15:06,160 that is a child element of the element 286 00:15:06,160 --> 00:15:09,130 that has to open class, right? 287 00:15:09,130 --> 00:15:13,410 And so here we can set the display a property back to block. 288 00:15:13,410 --> 00:15:15,223 So why does that work again? 289 00:15:16,190 --> 00:15:17,770 Well, in here we have, 290 00:15:17,770 --> 00:15:21,703 of course the element with the class of hidden box, right? 291 00:15:22,600 --> 00:15:27,070 And if this element, so the parent element of the hidden box 292 00:15:27,070 --> 00:15:30,850 has this class of open, right? 293 00:15:30,850 --> 00:15:34,520 So if open is present here on the parent element, 294 00:15:34,520 --> 00:15:37,233 then this selector here will apply, 295 00:15:38,930 --> 00:15:39,930 right? 296 00:15:39,930 --> 00:15:42,360 Because if this doesn't exist, 297 00:15:42,360 --> 00:15:46,080 so if open is not present on the parent element, 298 00:15:46,080 --> 00:15:48,250 then of course nothing's going to happen, 299 00:15:48,250 --> 00:15:52,020 because this selector here will not be applied anywhere. 300 00:15:52,020 --> 00:15:54,500 But if the open class is present, 301 00:15:54,500 --> 00:15:58,040 then this descendant selector here 302 00:15:58,040 --> 00:16:00,170 will of course, then work. 303 00:16:00,170 --> 00:16:02,973 And so that's why this is back now. 304 00:16:04,640 --> 00:16:06,150 To make it even clearer, 305 00:16:06,150 --> 00:16:07,603 let's see in the inspector. 306 00:16:10,830 --> 00:16:11,833 So, 307 00:16:13,130 --> 00:16:14,300 now here we are. 308 00:16:14,300 --> 00:16:16,443 So here we have that style of open, 309 00:16:17,320 --> 00:16:20,353 which is the parent of hidden box and the selector, 310 00:16:21,380 --> 00:16:23,640 but if we were to remove the open class 311 00:16:23,640 --> 00:16:25,243 here from the parent element, 312 00:16:27,200 --> 00:16:28,830 then hit enter. 313 00:16:28,830 --> 00:16:30,300 Now that's gone. 314 00:16:30,300 --> 00:16:35,283 And so now, also that rule is gone from the hidden box. 315 00:16:36,420 --> 00:16:38,193 So the one that we had here before, 316 00:16:39,140 --> 00:16:43,340 so this one is now gone because the class is also gone, 317 00:16:43,340 --> 00:16:44,930 the open class. 318 00:16:44,930 --> 00:16:49,130 And so therefore, this can no longer work, all right? 319 00:16:49,130 --> 00:16:50,793 So I hope that made sense, 320 00:16:52,070 --> 00:16:53,620 because this is actually, 321 00:16:53,620 --> 00:16:57,693 well, as I said before, something that is used all the time. 322 00:17:01,860 --> 00:17:02,693 Okay. 323 00:17:03,600 --> 00:17:06,720 So now it is the same idea as before, 324 00:17:06,720 --> 00:17:10,690 so whenever there is a number element, 325 00:17:10,690 --> 00:17:12,800 so an element with the class of number 326 00:17:12,800 --> 00:17:15,320 that is a child element of an element 327 00:17:15,320 --> 00:17:17,030 with the class of open, 328 00:17:17,030 --> 00:17:18,943 then color should be green. 329 00:17:21,240 --> 00:17:22,430 Well, which one is it? 330 00:17:22,430 --> 00:17:23,800 Yes. 331 00:17:23,800 --> 00:17:26,710 And we want this to happen also to the text, 332 00:17:26,710 --> 00:17:30,380 and so we can of course create a list here. 333 00:17:30,380 --> 00:17:32,430 So we need to write the same thing again. 334 00:17:33,560 --> 00:17:37,740 So open, which is the parent of text, 335 00:17:37,740 --> 00:17:39,970 and so again, this one will apply 336 00:17:39,970 --> 00:17:43,150 if there is an element with a class of text 337 00:17:43,150 --> 00:17:46,623 that is a children of an element with a class of open. 338 00:17:47,650 --> 00:17:49,463 And, there we go. 339 00:17:50,930 --> 00:17:52,450 So that works. 340 00:17:52,450 --> 00:17:55,350 And of course we can now try to add that class 341 00:17:55,350 --> 00:17:56,783 also to another item, 342 00:17:58,350 --> 00:17:59,760 so to this one, 343 00:17:59,760 --> 00:18:01,723 and now that should look just the same, 344 00:18:02,710 --> 00:18:05,010 and it does. 345 00:18:05,010 --> 00:18:06,050 Beautiful! 346 00:18:06,050 --> 00:18:09,430 But let's take that back because we only want it 347 00:18:09,430 --> 00:18:12,050 in this situation, in the second one. 348 00:18:12,050 --> 00:18:15,570 And so with this, we actually finished this small project, 349 00:18:15,570 --> 00:18:17,500 so this small component. 350 00:18:17,500 --> 00:18:19,970 So I hope that this was fun, 351 00:18:19,970 --> 00:18:23,040 and here are the main takeaways that I want you to take 352 00:18:23,040 --> 00:18:24,590 from this project, 353 00:18:24,590 --> 00:18:27,323 is first of all, this logic that we did here, 354 00:18:28,170 --> 00:18:32,420 so basically, this open state that we created 355 00:18:32,420 --> 00:18:34,290 simply by adding this class here 356 00:18:34,290 --> 00:18:37,940 to the parent element, right? 357 00:18:37,940 --> 00:18:41,720 Then I want you to take away this whole idea 358 00:18:41,720 --> 00:18:45,910 of setting a flex container to flex direction column, 359 00:18:45,910 --> 00:18:49,600 which remember, will essentially switch the main 360 00:18:49,600 --> 00:18:51,660 with the cross axis. 361 00:18:51,660 --> 00:18:53,740 And then another takeaway 362 00:18:53,740 --> 00:18:58,210 was how we built this layout here actually. 363 00:18:58,210 --> 00:19:00,980 So I think that this was another great use case 364 00:19:00,980 --> 00:19:05,980 of a CSS grid and another showcase of its power, right? 365 00:19:07,920 --> 00:19:11,270 So make sure to study the code that we did here, 366 00:19:11,270 --> 00:19:12,620 and then after that, 367 00:19:12,620 --> 00:19:16,480 we can together actually built our next component, 368 00:19:16,480 --> 00:19:19,380 which is again, gonna be really exciting, 369 00:19:19,380 --> 00:19:22,083 and so I can't wait to see you there. 26077

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