Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,360 --> 00:00:04,370
Let's now finally go back to coding.
2
00:00:04,370 --> 00:00:05,670
And so in this lecture,
3
00:00:05,670 --> 00:00:06,890
and the next one,
4
00:00:06,890 --> 00:00:10,323
we're going to build a beautiful accordion component.
5
00:00:11,620 --> 00:00:14,900
And it's going to be based on this accordion example
6
00:00:14,900 --> 00:00:17,540
that we saw in the last lecture.
7
00:00:17,540 --> 00:00:20,190
So, we're going to build something very similar
8
00:00:20,190 --> 00:00:23,340
which will look like this one on the right side.
9
00:00:23,340 --> 00:00:25,313
So, let's go do that.
10
00:00:26,950 --> 00:00:27,920
And as always,
11
00:00:27,920 --> 00:00:29,750
when we start a new section,
12
00:00:29,750 --> 00:00:31,913
we need our starter files.
13
00:00:33,150 --> 00:00:35,010
So here in starter,
14
00:00:35,010 --> 00:00:38,740
now we need folder number six.
15
00:00:38,740 --> 00:00:40,300
And so actually,
16
00:00:40,300 --> 00:00:42,340
this is only two images,
17
00:00:42,340 --> 00:00:44,193
but well, we will need it.
18
00:00:45,530 --> 00:00:46,363
All right.
19
00:00:47,670 --> 00:00:50,580
So, folder number six.
20
00:00:50,580 --> 00:00:52,850 line:15%
Here let's create a new window
21
00:00:52,850 --> 00:00:56,875 line:15%
and another trick would actually to be simply dragging
22
00:00:56,875 --> 00:01:00,440 line:15%
this folder here onto that icon.
23
00:01:00,440 --> 00:01:01,663 line:15%
So you can do that,
24
00:01:02,600 --> 00:01:04,200
so like this.
25
00:01:04,200 --> 00:01:06,190
It will then open up a new window
26
00:01:06,190 --> 00:01:08,610
already with that folder selected.
27
00:01:08,610 --> 00:01:12,640 line:15%
Or of course, you can also just create a new window
28
00:01:12,640 --> 00:01:15,790
and then open the project folder from there.
29
00:01:15,790 --> 00:01:18,223
So, like we have been doing up until this point.
30
00:01:20,290 --> 00:01:21,860
So both way works.
31
00:01:21,860 --> 00:01:24,763
And I actually prefer the first one that I showed you.
32
00:01:26,470 --> 00:01:31,150
And so now let's start by creating an HTML file right here.
33
00:01:31,150 --> 00:01:34,990
And we're going to create six components in this section
34
00:01:34,990 --> 00:01:38,790
and so I'm not going to call them index.html,
35
00:01:38,790 --> 00:01:42,597
but instead I'm calling this one 01-accordion,
36
00:01:45,190 --> 00:01:46,273
like this,
37
00:01:47,690 --> 00:01:49,003
dot HTML.
38
00:01:50,170 --> 00:01:51,160
All right.
39
00:01:51,160 --> 00:01:53,500
And since we are having so many files,
40
00:01:53,500 --> 00:01:55,620
I will actually keep each of these components
41
00:01:55,620 --> 00:01:59,710
here self contained inside of each HTML file.
42
00:01:59,710 --> 00:02:00,650
So what that means,
43
00:02:00,650 --> 00:02:03,770
is that I will not create an external CSS file
44
00:02:03,770 --> 00:02:05,100
for each of them,
45
00:02:05,100 --> 00:02:09,053
but instead we will simply use the style tag right here.
46
00:02:10,660 --> 00:02:12,640
So, to create the HTML,
47
00:02:12,640 --> 00:02:14,950
we have been always using it manually,
48
00:02:14,950 --> 00:02:19,230
but now let's actually have VS code generated for us.
49
00:02:19,230 --> 00:02:21,780
So exclamation mark, tab,
50
00:02:21,780 --> 00:02:23,440
and there we go.
51
00:02:23,440 --> 00:02:27,780
So now, the first thing is to change this to
52
00:02:27,780 --> 00:02:28,630
accordion
53
00:02:30,570 --> 00:02:31,950
component,
54
00:02:31,950 --> 00:02:34,530
and then remember we can simply declare
55
00:02:35,500 --> 00:02:37,653
or write the style tag in here,
56
00:02:38,740 --> 00:02:40,910
so that will then create a style element
57
00:02:40,910 --> 00:02:43,800
in which we can style our page.
58
00:02:43,800 --> 00:02:44,640
All right.
59
00:02:44,640 --> 00:02:47,773
Now, I will actually use a similar visual style
60
00:02:47,773 --> 00:02:51,400
than the project that we created in the last section.
61
00:02:51,400 --> 00:02:53,780
So therefore, what I'm going to do now
62
00:02:53,780 --> 00:02:56,630
is to open the CSS file off that one
63
00:02:56,630 --> 00:02:59,393
in order to copy some very simple styles.
64
00:03:00,510 --> 00:03:03,560
So, let's go here to the open menu
65
00:03:04,640 --> 00:03:07,150
and then on the desktop,
66
00:03:07,150 --> 00:03:10,760
we have the previous section
67
00:03:10,760 --> 00:03:14,053
and then actually I need the HTML as well,
68
00:03:15,910 --> 00:03:19,763
so that I can grab this link here for the inter font.
69
00:03:20,650 --> 00:03:23,480
So please go ahead and do the same thing now.
70
00:03:23,480 --> 00:03:26,500
So copy this link element here,
71
00:03:26,500 --> 00:03:29,760
which will include the inter typeface,
72
00:03:29,760 --> 00:03:30,593
so font.
73
00:03:32,780 --> 00:03:34,143
So that is done,
74
00:03:35,160 --> 00:03:36,970
and now in the CSS,
75
00:03:36,970 --> 00:03:39,633
we can get some of this stuff.
76
00:03:42,010 --> 00:03:43,440
So our spacing system,
77
00:03:43,440 --> 00:03:47,830
these colors, the universal selector, this reset,
78
00:03:47,830 --> 00:03:50,200
so we don't have to write it all over again
79
00:03:50,200 --> 00:03:53,030
because by now you already now how it works,
80
00:03:53,030 --> 00:03:55,363
and then here this body element as well.
81
00:03:56,550 --> 00:03:58,090
So let's take that,
82
00:03:58,090 --> 00:04:01,253
and so with this we've saved ourselves some time.
83
00:04:02,910 --> 00:04:05,240
This here we might actually not want-
84
00:04:05,240 --> 00:04:06,863
actually let's leave it there.
85
00:04:07,930 --> 00:04:11,320
And then here, I'm indenting just a little bit
86
00:04:11,320 --> 00:04:12,493
to make it look better.
87
00:04:16,080 --> 00:04:17,770
Let's get rid of some spaces
88
00:04:17,770 --> 00:04:20,380
and off this comment as well,
89
00:04:20,380 --> 00:04:23,323 line:15%
and here actually we don't want that border in this body.
90
00:04:25,450 --> 00:04:26,283
All right.
91
00:04:27,193 --> 00:04:30,500
And now, let's create a simple div element here,
92
00:04:30,500 --> 00:04:33,113
with the class of accordion.
93
00:04:37,730 --> 00:04:40,150
And now I will just write something here,
94
00:04:40,150 --> 00:04:41,023
let's say test.
95
00:04:42,300 --> 00:04:44,150
Okay, and so now we have something.
96
00:04:44,150 --> 00:04:45,770
Very basic setup.
97
00:04:45,770 --> 00:04:49,250
So we have some very simple styles for the body,
98
00:04:49,250 --> 00:04:52,963 line:15%
and so let's test that by clicking here on go live.
99
00:04:54,040 --> 00:04:57,520
So there we have our page with a live connection.
100
00:04:57,520 --> 00:05:00,600
And for some reason that didn't work on your computer,
101
00:05:00,600 --> 00:05:04,900
you can simply also open the HTML file directly.
102
00:05:04,900 --> 00:05:06,210
All right?
103
00:05:06,210 --> 00:05:08,600
But, so this did work.
104
00:05:08,600 --> 00:05:11,910
And so let's start by actually defining a width
105
00:05:11,910 --> 00:05:14,630
for this accordion element.
106
00:05:14,630 --> 00:05:18,433 line:15%
So our entire component will basically be this right here.
107
00:05:20,070 --> 00:05:25,070
So let's select this element based on this class,
108
00:05:25,090 --> 00:05:29,950
and I will give it a fixed width of 700 pixels,
109
00:05:29,950 --> 00:05:31,513
and I also want to center it.
110
00:05:33,040 --> 00:05:34,210
And remember for that,
111
00:05:34,210 --> 00:05:36,670
we can use the trick of setting the left
112
00:05:36,670 --> 00:05:38,700
and right margins to auto,
113
00:05:38,700 --> 00:05:41,440
and the top and bottom to something else.
114
00:05:41,440 --> 00:05:44,380
So let's say top and bottom 100 pixels,
115
00:05:44,380 --> 00:05:46,290
and then again left and right,
116
00:05:46,290 --> 00:05:47,970
we set them to auto.
117
00:05:47,970 --> 00:05:50,720
And that will automatically center this element
118
00:05:50,720 --> 00:05:52,890
inside of its parent.
119
00:05:52,890 --> 00:05:54,683
So in this case, that is the body.
120
00:05:55,540 --> 00:05:56,450
Just see that,
121
00:05:56,450 --> 00:05:58,250
let's give it some background color.
122
00:06:00,700 --> 00:06:03,713
And, well, any color works.
123
00:06:05,100 --> 00:06:06,630
All right.
124
00:06:06,630 --> 00:06:07,810
Nice.
125
00:06:07,810 --> 00:06:09,290
All right.
126
00:06:09,290 --> 00:06:10,570
Nice.
127
00:06:10,570 --> 00:06:13,400
So let's actually turn that off again,
128
00:06:13,400 --> 00:06:15,342
and now we can start filling up
129
00:06:15,342 --> 00:06:18,520
our HTML here a little bit.
130
00:06:18,520 --> 00:06:19,353
And for that,
131
00:06:19,353 --> 00:06:20,530
let's actually take a look
132
00:06:20,530 --> 00:06:22,060
at what we have here.
133
00:06:22,060 --> 00:06:24,130
So basically the final result,
134
00:06:24,130 --> 00:06:25,760
which is this.
135
00:06:25,760 --> 00:06:27,200
So you see that basically
136
00:06:27,200 --> 00:06:29,810
this accordion has three elements.
137
00:06:29,810 --> 00:06:31,840
So this first one and the third one
138
00:06:31,840 --> 00:06:34,470
are closed right now and,
139
00:06:34,470 --> 00:06:37,120
and the opened one looks like this.
140
00:06:37,120 --> 00:06:39,110
Now, of course we will not be able
141
00:06:39,110 --> 00:06:41,390
to add the functionality here.
142
00:06:41,390 --> 00:06:43,770
So when we click here somewhere,
143
00:06:43,770 --> 00:06:46,530
of course, this box does not open.
144
00:06:46,530 --> 00:06:48,650
So for that, we would need JavaScript.
145
00:06:48,650 --> 00:06:51,720
But of course, that's not what we're gonna do here
146
00:06:51,720 --> 00:06:53,380
in this section.
147
00:06:53,380 --> 00:06:55,380
But anyway, to get started,
148
00:06:55,380 --> 00:06:59,500
we will actually only build this element right here.
149
00:06:59,500 --> 00:07:03,360
So basically, only the open state like this.
150
00:07:03,360 --> 00:07:04,833
So here we have a number.
151
00:07:04,833 --> 00:07:07,260
Then we have this title here,
152
00:07:07,260 --> 00:07:09,120
so some kind of text.
153
00:07:09,120 --> 00:07:11,760
Then this icon pointing downward,
154
00:07:11,760 --> 00:07:14,350
and then here we have a box in there.
155
00:07:14,350 --> 00:07:17,040
So this box here contains this text
156
00:07:17,040 --> 00:07:18,460
and then this list.
157
00:07:18,460 --> 00:07:20,600
And so basically, it is this box
158
00:07:20,600 --> 00:07:24,050
with this content here that is hidden right here
159
00:07:24,050 --> 00:07:25,940
and right here.
160
00:07:25,940 --> 00:07:26,840
All right.
161
00:07:26,840 --> 00:07:30,640
So, later we will then hide basically this content here
162
00:07:30,640 --> 00:07:32,760
or actually here and here,
163
00:07:32,760 --> 00:07:36,850
and we will leave it visible right here in this box.
164
00:07:36,850 --> 00:07:37,910
Okay?
165
00:07:37,910 --> 00:07:42,220
So, the plan is to now create these four elements.
166
00:07:42,220 --> 00:07:45,190
So this number, this text, this icon,
167
00:07:45,190 --> 00:07:47,830
and then a box with this paragraph
168
00:07:47,830 --> 00:07:49,970
and this unordered list.
169
00:07:49,970 --> 00:07:50,960
All right?
170
00:07:50,960 --> 00:07:52,730
And then after that,
171
00:07:52,730 --> 00:07:55,780
we will style them and only then in the end,
172
00:07:55,780 --> 00:07:57,453
we will care about the layout.
173
00:07:59,200 --> 00:08:03,930 line:15%
So, the first thing is this number.
174
00:08:03,930 --> 00:08:05,040 line:15%
And I'm simply going to use
175
00:08:05,040 --> 00:08:08,580 line:15%
a generic paragraph element here
176
00:08:08,580 --> 00:08:09,963 line:15%
for all this text.
177
00:08:10,850 --> 00:08:12,200 line:15%
So that's zero two,
178
00:08:12,200 --> 00:08:15,790 line:15%
and of course it needs some kind of class as well.
179
00:08:15,790 --> 00:08:17,683 line:15%
So, number.
180
00:08:19,730 --> 00:08:23,333 line:15%
Then another p element with the class of text.
181
00:08:26,470 --> 00:08:29,260 line:15%
So, let me just copy what I have there.
182
00:08:29,260 --> 00:08:34,260 line:15%
So 'How long do I have to return my chair?'
183
00:08:35,680 --> 00:08:36,820 line:15%
All right.
184
00:08:36,820 --> 00:08:38,600
Then we have that icon,
185
00:08:38,600 --> 00:08:42,193
and for that let's actually use the hero icons again.
186
00:08:43,560 --> 00:08:46,783
So heroicons.com, I think.
187
00:08:48,550 --> 00:08:52,483
Okay, and now let's just search for that one.
188
00:08:54,350 --> 00:08:57,150
Yeah, so it's the 'chevron-down'.
189
00:08:57,150 --> 00:08:58,683
So copy SVG,
190
00:08:59,800 --> 00:09:01,060 line:15%
and let's paste that here
191
00:09:01,060 --> 00:09:03,203 line:15%
as the third child element.
192
00:09:05,790 --> 00:09:07,080 line:15%
Give it a save,
193
00:09:07,080 --> 00:09:10,053
and while it's already here in our page,
194
00:09:11,136 --> 00:09:15,070
let's give it a better class name.
195
00:09:15,070 --> 00:09:16,990
Let's just say icon.
196
00:09:16,990 --> 00:09:21,373
And then finally we need this hidden box here.
197
00:09:23,060 --> 00:09:26,590
So let's actually call that a hidden box.
198
00:09:26,590 --> 00:09:28,500
So since it is a box,
199
00:09:28,500 --> 00:09:31,800
I will simply use the generic div element.
200
00:09:31,800 --> 00:09:34,610
So this one doesn't need any semantic meaning,
201
00:09:34,610 --> 00:09:37,083
and so our div is just fine.
202
00:09:39,030 --> 00:09:40,203
So hidden box.
203
00:09:41,040 --> 00:09:42,170 line:15%
And inside of that,
204
00:09:42,170 --> 00:09:45,340 line:15%
there is some kind of paragraph and,
205
00:09:45,340 --> 00:09:47,980 line:15%
well, this one maybe doesn't need a class.
206
00:09:47,980 --> 00:09:49,840 line:15%
Let's just leave it like this.
207
00:09:49,840 --> 00:09:52,020 line:15%
And here we need some blind text.
208
00:09:52,020 --> 00:09:54,530 line:15%
So I'm not going to copy that text of course,
209
00:09:54,530 --> 00:09:56,370 line:15%
because remember that in VS code,
210
00:09:56,370 --> 00:09:59,610 line:15%
we can write lorem, like this,
211
00:09:59,610 --> 00:10:01,460 line:15%
and then that will generate a bunch
212
00:10:01,460 --> 00:10:03,093 line:15%
of blind text for us.
213
00:10:04,230 --> 00:10:05,373
So just like this.
214
00:10:07,159 --> 00:10:07,992
And let's see.
215
00:10:09,222 --> 00:10:12,140 line:15%
Yeah that looks kind of like the same amount of text.
216
00:10:12,140 --> 00:10:13,040
But if it's too much,
217
00:10:13,040 --> 00:10:15,590
we can just cut it a bit later.
218
00:10:15,590 --> 00:10:18,530
And so now let's create that unordered list.
219
00:10:18,530 --> 00:10:20,280
And remember, it is unordered
220
00:10:20,280 --> 00:10:23,143
because these here are simple bullet points.
221
00:10:24,780 --> 00:10:27,863
And so in there, each of them is a list item.
222
00:10:28,790 --> 00:10:31,493
And now, let's here again use lorem.
223
00:10:32,810 --> 00:10:35,520 line:15%
I will now cut this part here
224
00:10:35,520 --> 00:10:37,293 line:15%
and put that into the next one.
225
00:10:39,330 --> 00:10:41,190 line:15%
So paste that here now.
226
00:10:41,190 --> 00:10:42,860 line:15%
And now, we'll do the same again
227
00:10:45,370 --> 00:10:48,313 line:15%
because that content of course is a bit too long.
228
00:10:50,440 --> 00:10:52,120 line:15%
Okay, and maybe
229
00:10:54,670 --> 00:10:56,510 line:15%
let's leave that.
230
00:10:56,510 --> 00:10:57,720 line:15%
And so your content is going
231
00:10:57,720 --> 00:11:00,113 line:15%
to look a little bit different than mine now,
232
00:11:01,210 --> 00:11:03,490 line:15%
but that's not really a problem
233
00:11:03,490 --> 00:11:04,990 line:15%
because this is always random.
234
00:11:08,250 --> 00:11:11,180
Okay, so that looks good for now
235
00:11:11,180 --> 00:11:13,750
as far as the HTML goes.
236
00:11:13,750 --> 00:11:17,450
Oh actually we should wrap all of this content here
237
00:11:17,450 --> 00:11:19,123
inside yet another one.
238
00:11:20,030 --> 00:11:21,780
So right now inside of the accordion,
239
00:11:21,780 --> 00:11:25,150
we have number text, and so on and so forth.
240
00:11:25,150 --> 00:11:27,860
However, what we actually want in the accordion
241
00:11:27,860 --> 00:11:29,770
is these three elements.
242
00:11:29,770 --> 00:11:31,860
So these three items basically.
243
00:11:31,860 --> 00:11:34,440
So this first, the second, and the third item,
244
00:11:34,440 --> 00:11:36,730
of course, are individual elements.
245
00:11:36,730 --> 00:11:39,283
So elements inside of the accordion.
246
00:11:40,450 --> 00:11:44,230
But we right here have these elements as direct children,
247
00:11:44,230 --> 00:11:46,480
and so that's not correct.
248
00:11:46,480 --> 00:11:51,240
So let's simply create another div called an item.
249
00:11:53,880 --> 00:11:56,290
But this we don't want here.
250
00:11:56,290 --> 00:11:57,853
We want it at the very end.
251
00:12:00,060 --> 00:12:01,810
All right.
252
00:12:01,810 --> 00:12:03,360
So that's better.
253
00:12:03,360 --> 00:12:06,180
And now let's style all of this.
254
00:12:06,180 --> 00:12:08,430
And now it's time to use again
255
00:12:08,430 --> 00:12:10,790
that trick that I showed you before.
256
00:12:10,790 --> 00:12:11,940
So remember for that,
257
00:12:11,940 --> 00:12:13,820
we just select something.
258
00:12:13,820 --> 00:12:17,510
Then we can hit option or alt on our keyboard,
259
00:12:17,510 --> 00:12:19,670
and then if I double click here again,
260
00:12:19,670 --> 00:12:21,940
it will select the next class.
261
00:12:21,940 --> 00:12:22,773
And so like this,
262
00:12:22,773 --> 00:12:25,870
we don't have to copy paste them multiple times.
263
00:12:25,870 --> 00:12:28,190
We can just do it all at once.
264
00:12:28,190 --> 00:12:32,000
So again, I'm now hitting the option or alt key,
265
00:12:32,000 --> 00:12:33,700
double click on this class,
266
00:12:33,700 --> 00:12:35,530
then on this class,
267
00:12:35,530 --> 00:12:38,373
and finally this one here.
268
00:12:39,600 --> 00:12:40,450
All right.
269
00:12:40,450 --> 00:12:41,990
Now I copy it,
270
00:12:41,990 --> 00:12:44,370
and here inside of my style,
271
00:12:44,370 --> 00:12:47,810
I can now paste that
272
00:12:47,810 --> 00:12:51,963
and so now I can do this here a lot easier.
273
00:12:56,469 --> 00:12:59,023 line:15%
Okay, so almost done.
274
00:13:00,710 --> 00:13:02,880
Because this is always like,
275
00:13:02,880 --> 00:13:06,220
a lot of work selecting all of these elements
276
00:13:06,220 --> 00:13:07,463
in the very beginning.
277
00:13:08,390 --> 00:13:09,340
But now we're done with that,
278
00:13:09,340 --> 00:13:12,450
and so let's style them one by one.
279
00:13:12,450 --> 00:13:16,000
And I'm gonna start basically with the visual styles.
280
00:13:16,000 --> 00:13:18,963
So of the number, the text, and this icon here.
281
00:13:19,800 --> 00:13:21,430
And let's start with the icon actually
282
00:13:21,430 --> 00:13:24,073
because it is taking up a lot of space.
283
00:13:25,100 --> 00:13:26,993
So let's make it really small.
284
00:13:28,460 --> 00:13:32,880
So remember that these icons were designed for 24 pixels,
285
00:13:32,880 --> 00:13:36,023
and so I'm actually respecting that size.
286
00:13:37,700 --> 00:13:39,910 line:15%
And now the color, remember,
287
00:13:39,910 --> 00:13:43,240 line:15%
we can manipulate it using the stroke property.
288
00:13:43,240 --> 00:13:46,033
And we have our color of value up here.
289
00:13:49,870 --> 00:13:50,743 line:15%
Okay.
290
00:13:52,174 --> 00:13:54,630 line:15%
And that looks a lot better already.
291
00:13:54,630 --> 00:13:59,630
Okay, let's take a look at our original here.
292
00:13:59,800 --> 00:14:04,203
And so, next up let's style the number and the text.
293
00:14:05,400 --> 00:14:09,673
And let's use the font size of 24 pixels here.
294
00:14:12,560 --> 00:14:17,550
So number, font size, 24 pixels,
295
00:14:17,550 --> 00:14:20,290
and let's also make it a bit bolder
296
00:14:20,290 --> 00:14:23,060
because this is an important piece of content
297
00:14:23,060 --> 00:14:26,360
and so we make it bold in order
298
00:14:26,360 --> 00:14:28,920
to give it some more emphasis.
299
00:14:28,920 --> 00:14:30,913
Oh and also the text color,
300
00:14:31,760 --> 00:14:34,060
let's make it green at this point
301
00:14:34,060 --> 00:14:35,270
even though a bit later,
302
00:14:35,270 --> 00:14:37,570
we will actually make this in a different way.
303
00:14:39,310 --> 00:14:42,920
So let's copy this, or actually,
304
00:14:42,920 --> 00:14:46,120
if it's exactly the same style as the text here,
305
00:14:46,120 --> 00:14:48,860
let us put the selector here
306
00:14:48,860 --> 00:14:50,593
as the second one in this list.
307
00:14:51,490 --> 00:14:54,710
So remember, as we learned way back,
308
00:14:54,710 --> 00:14:57,480
we can basically create a list of selectors.
309
00:14:57,480 --> 00:15:00,180
And so now this declaration block here
310
00:15:00,180 --> 00:15:05,180
will apply to this one and to this one, right?
311
00:15:05,210 --> 00:15:06,360
Give it a save.
312
00:15:06,360 --> 00:15:08,960
Now we cannot see it,
313
00:15:08,960 --> 00:15:10,570
but there you go.
314
00:15:10,570 --> 00:15:11,700
Great.
315
00:15:11,700 --> 00:15:15,910
Now next up, let's style this text here
316
00:15:15,910 --> 00:15:17,653
and this unordered list.
317
00:15:19,110 --> 00:15:19,943
All right.
318
00:15:19,943 --> 00:15:21,450
And I didn't give them a class,
319
00:15:21,450 --> 00:15:25,520
so let's just say hidden box,
320
00:15:25,520 --> 00:15:29,920
and then select the p as the child there.
321
00:15:29,920 --> 00:15:31,300
And here all I want to do
322
00:15:31,300 --> 00:15:33,950
is to improve the line height
323
00:15:33,950 --> 00:15:34,853
and set it to 1.6,
324
00:15:36,510 --> 00:15:38,863
and also give it some margin to the bottom.
325
00:15:42,010 --> 00:15:44,863
So let's say 24 pixels.
326
00:15:46,690 --> 00:15:49,060
Okay, so that looks better.
327
00:15:49,060 --> 00:15:52,563
And now finally also, the u-l.
328
00:15:56,040 --> 00:15:57,110
Okay.
329
00:15:57,110 --> 00:16:00,203
So we want to set a lighter text here on this.
330
00:16:01,270 --> 00:16:03,780
And so, in order to do that,
331
00:16:03,780 --> 00:16:06,060
we don't have to select each of them,
332
00:16:06,060 --> 00:16:09,470
but instead we can simply set that color on the parent
333
00:16:09,470 --> 00:16:12,960
and then that will move down,
334
00:16:12,960 --> 00:16:15,760
and so that will then be inherited.
335
00:16:15,760 --> 00:16:18,130
Now about that lighter color,
336
00:16:18,130 --> 00:16:19,270
this one here,
337
00:16:19,270 --> 00:16:22,703
let me actually get that from the open color again.
338
00:16:24,360 --> 00:16:25,373
Open colors.
339
00:16:26,830 --> 00:16:28,203
So that is this one.
340
00:16:30,680 --> 00:16:33,583
And let's use this one here, let's say.
341
00:16:42,170 --> 00:16:43,380
All right.
342
00:16:43,380 --> 00:16:46,293
Wow that's a little bit too much on the light side.
343
00:16:48,330 --> 00:16:50,103
So let's go with this one.
344
00:16:54,570 --> 00:16:56,430
Yeah, that looks better.
345
00:16:56,430 --> 00:16:59,780
Maybe it is not really the best choice here
346
00:16:59,780 --> 00:17:01,660
in terms of accessibility,
347
00:17:01,660 --> 00:17:06,400
but, well let's just leave it as this for now.
348
00:17:06,400 --> 00:17:09,370
We're gonna worry about that in some other project.
349
00:17:09,370 --> 00:17:11,033
So in the next section actually.
350
00:17:12,370 --> 00:17:14,340
Now here we need to then
351
00:17:14,340 --> 00:17:16,630
also set some margin on the left.
352
00:17:16,630 --> 00:17:19,800
So, basically in order to align this a little bit,
353
00:17:19,800 --> 00:17:22,030
so the bullet points with the p,
354
00:17:22,030 --> 00:17:23,063
with the paragraph.
355
00:17:23,950 --> 00:17:26,600 line:15%
So margin left,
356
00:17:26,600 --> 00:17:29,293 line:15%
and now 16 pixels.
357
00:17:31,100 --> 00:17:32,890 line:15%
That might work.
358
00:17:32,890 --> 00:17:34,410 line:15%
That looks aligned.
359
00:17:34,410 --> 00:17:37,870 line:15%
Well maybe it needs to be a little bit more.
360
00:17:37,870 --> 00:17:39,630 line:15%
Yep, that's correct.
361
00:17:39,630 --> 00:17:42,040 line:15%
So here we broke a little bit of our system,
362
00:17:42,040 --> 00:17:43,890 line:15%
but in this case it was necessary
363
00:17:43,890 --> 00:17:46,060 line:15%
because only with that value,
364
00:17:46,060 --> 00:17:47,800 line:15%
it's not perfectly aligned.
365
00:17:47,800 --> 00:17:50,550 line:15%
And actually not yet, I think.
366
00:17:50,550 --> 00:17:52,210 line:15%
Now it's perfect.
367
00:17:52,210 --> 00:17:53,850
All right, now next we want
368
00:17:53,850 --> 00:17:57,320
to create some space here between these items.
369
00:17:57,320 --> 00:18:00,590
And so, now it's time that I will finally show you
370
00:18:00,590 --> 00:18:02,990
something new in CSS and,
371
00:18:02,990 --> 00:18:05,350
in particular, in flexbox.
372
00:18:05,350 --> 00:18:06,540
Now you might be wondering,
373
00:18:06,540 --> 00:18:09,640
'why is he going to use flexbox?'
374
00:18:09,640 --> 00:18:11,240
I mean, we don't really want
375
00:18:11,240 --> 00:18:14,320
these elements side by side, right?
376
00:18:14,320 --> 00:18:16,530
And that is totally correct.
377
00:18:16,530 --> 00:18:19,260
However, we can still use flexbox
378
00:18:19,260 --> 00:18:20,860
by doing something new,
379
00:18:20,860 --> 00:18:24,800
which I hinted at when we first learned flexbox,
380
00:18:24,800 --> 00:18:26,023
but we never did it.
381
00:18:27,030 --> 00:18:30,560
So let me start by explaining why I would use flexbox
382
00:18:30,560 --> 00:18:31,920
for something like this,
383
00:18:31,920 --> 00:18:33,363
and then also how.
384
00:18:34,220 --> 00:18:36,400
So, in order to create this space
385
00:18:36,400 --> 00:18:38,170
between these elements here,
386
00:18:38,170 --> 00:18:41,010
I would now have to select all of them
387
00:18:41,010 --> 00:18:43,460
and then add a margin to the bottom
388
00:18:43,460 --> 00:18:46,403
to all of them except for the last one.
389
00:18:47,420 --> 00:18:50,453 line:15%
So again, I would have to select them now.
390
00:18:51,910 --> 00:18:53,723 line:15%
I can actually do that very quickly.
391
00:18:56,970 --> 00:19:00,473 line:15%
Margin bottom of 12 pixels.
392
00:19:01,990 --> 00:19:03,230 line:15%
Like this.
393
00:19:03,230 --> 00:19:06,330 line:15%
And then I would also have to select the last one
394
00:19:06,330 --> 00:19:09,150 line:15%
and set it back to zero, right?
395
00:19:09,150 --> 00:19:11,230
However, we can have all of this
396
00:19:11,230 --> 00:19:12,970
in a much easier way,
397
00:19:12,970 --> 00:19:15,100
which is by using flexbox
398
00:19:15,100 --> 00:19:17,670
and then setting the gap property.
399
00:19:17,670 --> 00:19:20,830
However, that gap is usually horizontally.
400
00:19:20,830 --> 00:19:23,910
And also, if we set something to flexbox,
401
00:19:23,910 --> 00:19:27,630
it will put the element side by side, right?
402
00:19:27,630 --> 00:19:31,580
However, there is a really nice and very important trick,
403
00:19:31,580 --> 00:19:34,520
which is that we can set the flex direction
404
00:19:34,520 --> 00:19:36,713
of the container to column.
405
00:19:37,870 --> 00:19:40,113 line:15%
So let's remove all of this here.
406
00:19:41,840 --> 00:19:43,020 line:15%
All right.
407
00:19:43,020 --> 00:19:46,000 line:15%
And then, right here let's set this
408
00:19:46,000 --> 00:19:47,453 line:15%
to a flex container.
409
00:19:49,400 --> 00:19:51,320 line:15%
So display flex.
410
00:19:51,320 --> 00:19:53,120 line:15%
And so by default again,
411
00:19:53,120 --> 00:19:57,750 line:15%
the elements will be set side by side like this, right?
412
00:19:57,750 --> 00:19:58,980 line:15%
But as I mentioned,
413
00:19:58,980 --> 00:20:02,203 line:15%
we can now say flex direction,
414
00:20:03,430 --> 00:20:05,263 line:15%
and set it to column.
415
00:20:06,190 --> 00:20:07,990 line:15%
So by default, it is row.
416
00:20:07,990 --> 00:20:09,750 line:15%
And now, if we set column,
417
00:20:09,750 --> 00:20:13,833 line:15%
it will simply look exactly like before, all right?
418
00:20:14,670 --> 00:20:17,513 line:15%
However, if we now define the gap property,
419
00:20:18,870 --> 00:20:22,150 line:15%
so gap let's say 12 pixels,
420
00:20:22,150 --> 00:20:24,130 line:15%
then see what happens.
421
00:20:24,130 --> 00:20:27,250 line:15%
So you see that now the gap property
422
00:20:27,250 --> 00:20:30,480 line:15%
basically was applied vertically.
423
00:20:30,480 --> 00:20:32,950 line:15%
So between these elements like this,
424
00:20:32,950 --> 00:20:35,930 line:15%
and no longer horizontally, right?
425
00:20:35,930 --> 00:20:38,800 line:15%
So that is the power of flex direction
426
00:20:38,800 --> 00:20:40,200 line:15%
and let's actually take a look
427
00:20:40,200 --> 00:20:43,400 line:15%
at a graphical explanation to make really sure
428
00:20:43,400 --> 00:20:46,403 line:15%
that you understand this very important concept.
429
00:20:47,650 --> 00:20:49,000
Now here as an example,
430
00:20:49,000 --> 00:20:52,090
I'm actually using the accordion element but,
431
00:20:52,090 --> 00:20:54,220
of course, that's not important.
432
00:20:54,220 --> 00:20:56,570
The principle is exactly the same.
433
00:20:56,570 --> 00:20:59,390
So anyway, right here we can see
434
00:20:59,390 --> 00:21:02,260
what flexbox is by default.
435
00:21:02,260 --> 00:21:05,650
So the main axis is basically horizontally,
436
00:21:05,650 --> 00:21:08,360
and the elements are side by side right now
437
00:21:08,360 --> 00:21:11,490
because we have display set to flex,
438
00:21:11,490 --> 00:21:14,850
and we also have some gap there of 24 pixels.
439
00:21:14,850 --> 00:21:17,790
And so that's why there is some space horizontally
440
00:21:17,790 --> 00:21:19,350
between the items.
441
00:21:19,350 --> 00:21:22,860
However, if we now set flex direction to column,
442
00:21:22,860 --> 00:21:24,573
then watch what happens.
443
00:21:25,590 --> 00:21:27,640
So you see,
444
00:21:27,640 --> 00:21:29,610
that now basically the elements
445
00:21:29,610 --> 00:21:32,190
are stacked one after the other
446
00:21:32,190 --> 00:21:36,060
because the main axis rotated by 90 degree.
447
00:21:36,060 --> 00:21:36,893
And so now,
448
00:21:36,893 --> 00:21:40,250
the main axis no longer goes from left to right,
449
00:21:40,250 --> 00:21:42,220
but from top to bottom.
450
00:21:42,220 --> 00:21:43,430
Or in other words,
451
00:21:43,430 --> 00:21:45,880
the main axis is now vertically
452
00:21:45,880 --> 00:21:47,970
and no longer horizontally.
453
00:21:47,970 --> 00:21:48,900
On the other hand,
454
00:21:48,900 --> 00:21:51,840
the cross axis which used to be vertically,
455
00:21:51,840 --> 00:21:53,830
is now horizontally.
456
00:21:53,830 --> 00:21:56,350
And so now, everything is different.
457
00:21:56,350 --> 00:21:57,900
Everything in flexbox
458
00:21:57,900 --> 00:22:01,840
has now turned by 90 degrees, basically.
459
00:22:01,840 --> 00:22:04,180
So what this means is that now,
460
00:22:04,180 --> 00:22:07,880
align items no longer aligns the items vertically,
461
00:22:07,880 --> 00:22:10,110
but horizontally.
462
00:22:10,110 --> 00:22:11,590
And in the same sense,
463
00:22:11,590 --> 00:22:16,270
justify content now no longer aligns the items horizontally,
464
00:22:16,270 --> 00:22:17,990
but vertically.
465
00:22:17,990 --> 00:22:19,720
And finally of course,
466
00:22:19,720 --> 00:22:21,750
as we already saw in practice,
467
00:22:21,750 --> 00:22:25,370
the gap property now acts like margin bottom
468
00:22:25,370 --> 00:22:29,840
and no longer like margin right, okay?
469
00:22:29,840 --> 00:22:32,840
So this is really important for you to understand
470
00:22:32,840 --> 00:22:36,440
as this feature is actually one of the main features
471
00:22:36,440 --> 00:22:37,980
of flexbox.
472
00:22:37,980 --> 00:22:40,641
It gives flexbox even more power
473
00:22:40,641 --> 00:22:43,880
than we already thought that it had, all right?
474
00:22:44,950 --> 00:22:46,970
So I hope that this made sense,
475
00:22:46,970 --> 00:22:49,353
and so let's now go back to our code.
476
00:22:50,940 --> 00:22:53,340
And to see this explanation basically again,
477
00:22:53,340 --> 00:22:55,173
let's inspect that here.
478
00:22:59,000 --> 00:23:01,760 line:15%
So, right here,
479
00:23:01,760 --> 00:23:06,110 line:15%
we now see that gap there between the elements, right?
480
00:23:06,110 --> 00:23:07,700 line:15%
And we can even turn this on,
481
00:23:07,700 --> 00:23:12,450 line:15%
and then it stays permanently just like in CSS script,
482
00:23:12,450 --> 00:23:13,283 line:15%
and of course,
483
00:23:13,283 --> 00:23:16,580 line:15%
if we took out the flex direction to column,
484
00:23:16,580 --> 00:23:18,770 line:15%
then they would be side by side
485
00:23:18,770 --> 00:23:22,653 line:15%
and this space here would be horizontally, right?
486
00:23:23,770 --> 00:23:28,710 line:15%
Now let's also just try to use align items here
487
00:23:28,710 --> 00:23:32,610 line:15%
because as you saw, this now should work differently.
488
00:23:32,610 --> 00:23:35,220
So remember that usually align items
489
00:23:35,220 --> 00:23:39,363
would align our flex items vertically, right?
490
00:23:41,340 --> 00:23:43,540
But what do you expect will happen now
491
00:23:43,540 --> 00:23:44,773
as we center them?
492
00:23:46,130 --> 00:23:47,640
Well you see,
493
00:23:47,640 --> 00:23:50,193
now they got aligned horizontally.
494
00:23:51,910 --> 00:23:55,980 line:15%
So again, if we turned flex direction off here,
495
00:23:55,980 --> 00:24:00,400 line:15%
then you see that the alignment will be vertically, right?
496
00:24:00,400 --> 00:24:01,740 line:15%
So this one is taller
497
00:24:01,740 --> 00:24:03,410 line:15%
and these are a bit smaller
498
00:24:03,410 --> 00:24:06,320 line:15%
and we see that they are vertically aligned.
499
00:24:06,320 --> 00:24:08,550 line:15%
But by turning this on,
500
00:24:08,550 --> 00:24:11,720 line:15%
then everything rotates 90 degrees basically,
501
00:24:11,720 --> 00:24:14,233 line:15%
and now the alignment is horizontally.
502
00:24:15,070 --> 00:24:15,903 line:15%
So you see,
503
00:24:15,903 --> 00:24:19,210 line:15%
that all of them here are like basically centered.
504
00:24:19,210 --> 00:24:21,950 line:15%
So along the cross axis,
505
00:24:21,950 --> 00:24:25,170 line:15%
which now is going from left to right.
506
00:24:25,170 --> 00:24:28,463 line:15%
So here where I'm moving my mouse, right?
507
00:24:29,900 --> 00:24:31,200
So now of course we don't want
508
00:24:31,200 --> 00:24:32,840
that here in this example,
509
00:24:32,840 --> 00:24:34,730
but this was just to demonstrate
510
00:24:34,730 --> 00:24:38,943
how the cross and the main axis did actually rotate.
511
00:24:39,860 --> 00:24:42,650
And actually I think this is too much space,
512
00:24:42,650 --> 00:24:45,913
and that is because I did not reset the line height.
513
00:24:46,770 --> 00:24:48,010
So, many times what I do,
514
00:24:48,010 --> 00:24:51,710
is to set the line height here on the body to one,
515
00:24:51,710 --> 00:24:53,900
and so basically resetting it.
516
00:24:53,900 --> 00:24:55,600
So, since this is about text,
517
00:24:55,600 --> 00:24:58,480
this property it will get inherited,
518
00:24:58,480 --> 00:25:01,777
and so we can put it in the body.
519
00:25:01,777 --> 00:25:03,980
And so now the space that we had,
520
00:25:03,980 --> 00:25:06,010
or some of it is gone,
521
00:25:06,010 --> 00:25:08,710
and it looks better like this.
522
00:25:08,710 --> 00:25:09,610
All right,
523
00:25:09,610 --> 00:25:13,480
so we have some decent visual styling going on here,
524
00:25:13,480 --> 00:25:15,880
and so for now in this lecture,
525
00:25:15,880 --> 00:25:16,990
that's it.
526
00:25:16,990 --> 00:25:18,100
And so, in the next one,
527
00:25:18,100 --> 00:25:21,530
we will take care of finally building the layout
528
00:25:21,530 --> 00:25:23,800
and then also add the two other elements
529
00:25:23,800 --> 00:25:25,470
to our accordion.
530
00:25:25,470 --> 00:25:27,060
So take a small break,
531
00:25:27,060 --> 00:25:28,663
and then I'll see you back here.
37286
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.