Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,660 --> 00:00:03,960
And let's keep working
2
00:00:03,960 --> 00:00:06,883
and actually finish our hero section.
3
00:00:08,420 --> 00:00:11,230
And this is where we left off.
4
00:00:11,230 --> 00:00:15,920
And what we want to do now is to vertically center this box,
5
00:00:15,920 --> 00:00:18,850
which has all of this content, right,
6
00:00:18,850 --> 00:00:20,320
but at the same time,
7
00:00:20,320 --> 00:00:24,393
keeping this navigation bar here at the very top.
8
00:00:25,670 --> 00:00:29,530
So let's explore different ways of actually doing that.
9
00:00:29,530 --> 00:00:32,140
And probably the first thing that comes to mind
10
00:00:32,140 --> 00:00:35,020
would be flexbox, right?
11
00:00:35,020 --> 00:00:37,973
So let's try out if that would be a good fit.
12
00:00:38,860 --> 00:00:42,973
So basically applying flexbox here on the entire header.
13
00:00:44,690 --> 00:00:46,467
So let's see.
14
00:00:47,520 --> 00:00:51,310
Display, flex,
15
00:00:51,310 --> 00:00:54,240
and then in order to vertically center,
16
00:00:54,240 --> 00:00:59,213
align items and center.
17
00:01:00,620 --> 00:01:02,280
So let's see.
18
00:01:02,280 --> 00:01:04,290
But that would, of course,
19
00:01:04,290 --> 00:01:06,990
first put these two elements side by side
20
00:01:06,990 --> 00:01:09,510
and then vertically center them.
21
00:01:09,510 --> 00:01:11,930
So it looks nice on this one here,
22
00:01:11,930 --> 00:01:15,200
but it does not look good on the navigation bar
23
00:01:15,200 --> 00:01:19,250
because we actually want this one to stay at the very top.
24
00:01:19,250 --> 00:01:23,660
And so flexbox is probably not the best way here to go.
25
00:01:23,660 --> 00:01:25,170
Now, in order to solve this,
26
00:01:25,170 --> 00:01:27,540
there are actually multiple ways.
27
00:01:27,540 --> 00:01:29,159
So there are multiple ways
28
00:01:29,159 --> 00:01:32,530
in which we can achieve this layout,
29
00:01:32,530 --> 00:01:35,190
so this design here that we want,
30
00:01:35,190 --> 00:01:37,210
but the one that we're going to use
31
00:01:37,210 --> 00:01:40,029
is to basically vertically center this box here
32
00:01:40,029 --> 00:01:42,590
using that trick that I showed you earlier
33
00:01:42,590 --> 00:01:44,330
with absolute positioning
34
00:01:44,330 --> 00:01:48,500
and then using the transform function with translate.
35
00:01:48,500 --> 00:01:49,743
So, remember that?
36
00:01:50,790 --> 00:01:54,500
So I actually showed you a diagram back then.
37
00:01:54,500 --> 00:01:56,863
And so now let's do the same thing here.
38
00:01:59,170 --> 00:02:01,343
So this one we don't need.
39
00:02:02,819 --> 00:02:07,453
And instead what we now want is to center this element here,
40
00:02:08,300 --> 00:02:09,730
so this container.
41
00:02:09,730 --> 00:02:11,790
And so actually we need to give this here
42
00:02:11,790 --> 00:02:13,493
a different class name.
43
00:02:14,690 --> 00:02:16,320
So this should not be different
44
00:02:16,320 --> 00:02:18,600
because of course, it's absolutely centered,
45
00:02:18,600 --> 00:02:20,890
and so the styles that we need
46
00:02:20,890 --> 00:02:23,283
are different than the ones from the container.
47
00:02:24,290 --> 00:02:27,893
So let's called this one here the header container.
48
00:02:29,010 --> 00:02:29,993
Copy this.
49
00:02:31,150 --> 00:02:35,650
And after the navigation,
50
00:02:35,650 --> 00:02:37,883
which is how it looks like in the code,
51
00:02:38,900 --> 00:02:43,010
and we still want the width to be 1200 pixels.
52
00:02:43,010 --> 00:02:44,580
So that is the same.
53
00:02:44,580 --> 00:02:48,393
But now remember we want to position it absolutely.
54
00:02:50,580 --> 00:02:52,733
Position absolute.
55
00:02:54,150 --> 00:02:58,010
And let's start here by putting it at left 50%
56
00:02:59,600 --> 00:03:01,950
and right 50%
57
00:03:03,850 --> 00:03:05,770
because remember it that we actually want
58
00:03:05,770 --> 00:03:08,250
to center this element, right,
59
00:03:08,250 --> 00:03:10,973
and so 50% is kind of the middle.
60
00:03:11,909 --> 00:03:13,730
But of course, we then will need to use
61
00:03:13,730 --> 00:03:15,670
the transform function as well.
62
00:03:15,670 --> 00:03:18,780
But for now, let's take a look at what it looks like
63
00:03:18,780 --> 00:03:20,410
like this.
64
00:03:20,410 --> 00:03:24,173
And so let's even give us some background color here again.
65
00:03:25,691 --> 00:03:27,173
And let's say violet.
66
00:03:28,970 --> 00:03:30,213
All right.
67
00:03:31,360 --> 00:03:35,310
So it did move already 50% here of the parent element
68
00:03:35,310 --> 00:03:38,540
to the right, but not to the bottom.
69
00:03:38,540 --> 00:03:41,940
And I think that is because we forgot to actually set
70
00:03:41,940 --> 00:03:44,063
the relatively positioned container.
71
00:03:45,600 --> 00:03:48,870
So we want this element here to be absolutely positioned
72
00:03:48,870 --> 00:03:52,210
inside of the header, right.
73
00:03:52,210 --> 00:03:56,290
And so never forget to then set the position relative
74
00:03:56,290 --> 00:03:58,350
on that one.
75
00:03:58,350 --> 00:04:02,350
So, well actually here, we also have a mistake.
76
00:04:02,350 --> 00:04:05,550
So of course, it needs to be 50% from the left
77
00:04:05,550 --> 00:04:08,423
and from the top, not from the right.
78
00:04:09,320 --> 00:04:10,553
That would not work.
79
00:04:11,810 --> 00:04:13,380
No, right.
80
00:04:13,380 --> 00:04:18,030
So basically, at this point here it is now 50% from the top
81
00:04:18,030 --> 00:04:20,090
and from the right.
82
00:04:20,090 --> 00:04:23,970
And remember that these 50% are in relation
83
00:04:23,970 --> 00:04:26,160
to the parent element.
84
00:04:26,160 --> 00:04:31,100
So it's 50% of this parent element here to the bottom
85
00:04:31,100 --> 00:04:36,100
and also 50% of this parent element width here to the right.
86
00:04:37,100 --> 00:04:39,620
Okay, and so now we need to fix that
87
00:04:39,620 --> 00:04:42,790
by basically moving it up a little bit back
88
00:04:42,790 --> 00:04:44,860
so that it's actually in the middle.
89
00:04:44,860 --> 00:04:47,610
So I hope you remember this technique.
90
00:04:47,610 --> 00:04:51,210
And if not, you can always go back and look at that slide
91
00:04:51,210 --> 00:04:54,750
with that visual explanation that I showed you.
92
00:04:54,750 --> 00:04:58,060
But what we will do now is to use the transform property
93
00:04:58,950 --> 00:05:01,160
with the translate function,
94
00:05:01,160 --> 00:05:06,160
and then we will move it back up 50% of the element's width
95
00:05:06,300 --> 00:05:07,863
and off the element's height.
96
00:05:09,450 --> 00:05:13,330
So minus 50 in both cases right here.
97
00:05:13,330 --> 00:05:15,630
And again, I will write it down here
98
00:05:15,630 --> 00:05:20,630
that these are in relation to the element size,
99
00:05:22,290 --> 00:05:27,290
while these two are in relation to the parent size.
100
00:05:29,790 --> 00:05:32,580
And so that is the reason why this works
101
00:05:32,580 --> 00:05:36,180
and why it looks beautifully like this now.
102
00:05:36,180 --> 00:05:41,180
So if we change this, well at least to these 1200 pixels,
103
00:05:41,910 --> 00:05:44,400
then it stays nicely in the center,
104
00:05:44,400 --> 00:05:48,020
and actually it will stay in the center forever.
105
00:05:48,020 --> 00:05:50,893
And of course, also the same vertically.
106
00:05:51,860 --> 00:05:54,770
So you see, it really stays in the top,
107
00:05:54,770 --> 00:05:58,630
even if it has to overlap this navigation bar here
108
00:05:58,630 --> 00:06:00,985
in this extreme situation.
109
00:06:00,985 --> 00:06:05,690
Okay, so this is exactly what we wanted.
110
00:06:05,690 --> 00:06:07,680
So that's amazing.
111
00:06:07,680 --> 00:06:10,950
And now comparing it to this one here,
112
00:06:10,950 --> 00:06:15,240
you see that here, actually, the text kind of finishes here
113
00:06:15,240 --> 00:06:19,710
like it looks like in the middle of the page, right.
114
00:06:19,710 --> 00:06:21,910
So that maybe looks like it's a little bit
115
00:06:21,910 --> 00:06:23,950
difficult to achieve,
116
00:06:23,950 --> 00:06:26,013
but actually, it's very easy.
117
00:06:27,340 --> 00:06:29,970
So basically, what we want is to simply have
118
00:06:29,970 --> 00:06:31,900
another container here,
119
00:06:31,900 --> 00:06:34,549
and so that element will then simply occupy
120
00:06:34,549 --> 00:06:36,770
50% of the width.
121
00:06:36,770 --> 00:06:40,320
And so that will then contain these elements, right.
122
00:06:40,320 --> 00:06:41,590
And so by doing that,
123
00:06:41,590 --> 00:06:44,646
we basically leave some space here for her face
124
00:06:44,646 --> 00:06:48,040
and for this part here of the background image.
125
00:06:48,040 --> 00:06:51,500
And then we have this texture beautifully on top
126
00:06:51,500 --> 00:06:53,123
of this blurred part.
127
00:06:53,960 --> 00:06:56,215
So that's why I chose to put the text
128
00:06:56,215 --> 00:07:00,680
and all this content here really on the left side.
129
00:07:00,680 --> 00:07:04,683
Okay, of course there could be other design decisions.
130
00:07:05,650 --> 00:07:09,410
So I also showed you that we could actually center the text,
131
00:07:09,410 --> 00:07:11,103
which is what some websites do.
132
00:07:12,320 --> 00:07:15,313
And just as an aside, this would be very easy.
133
00:07:16,490 --> 00:07:20,550
All we would have to do is on the container element,
134
00:07:20,550 --> 00:07:23,603
so the container element of those texts elements,
135
00:07:24,750 --> 00:07:28,710
here we would simply have to do text align center.
136
00:07:28,710 --> 00:07:30,890
And so this would work quite nice
137
00:07:30,890 --> 00:07:33,040
if the image was different.
138
00:07:33,040 --> 00:07:35,880
So basically, if the focus point of the image
139
00:07:35,880 --> 00:07:38,090
was down here in the bottom, for example,
140
00:07:38,090 --> 00:07:40,540
then this would work perfectly,
141
00:07:40,540 --> 00:07:42,890
but that's not the case,
142
00:07:42,890 --> 00:07:44,680
so let's comment that out.
143
00:07:44,680 --> 00:07:46,080
And then, as I was saying,
144
00:07:46,080 --> 00:07:49,493
we will simply create another element right here.
145
00:07:52,490 --> 00:07:56,567
So let's call this the header-container-inner.
146
00:08:00,840 --> 00:08:02,763
Okay, then moving that down.
147
00:08:06,370 --> 00:08:10,933
So header-container-inner, let's put it right here.
148
00:08:13,310 --> 00:08:16,160
And as I was saying, all we have to do is give this one
149
00:08:16,160 --> 00:08:19,850
a width of 50%, which is again,
150
00:08:19,850 --> 00:08:22,420
in relation to the parent element.
151
00:08:22,420 --> 00:08:27,420
So it will essentially be 600 pixels, so half of 1200,
152
00:08:27,550 --> 00:08:30,650
but let's start to get used to using percentages
153
00:08:30,650 --> 00:08:31,973
for this kind of thing.
154
00:08:33,110 --> 00:08:35,750
Now, just some background color very quickly,
155
00:08:35,750 --> 00:08:40,750
just for debugging, and there we go.
156
00:08:40,990 --> 00:08:43,060
So the contrast here is quite bad,
157
00:08:43,060 --> 00:08:47,140
but we can see that actually this worked.
158
00:08:47,140 --> 00:08:50,020
So now this is the container for the text,
159
00:08:50,020 --> 00:08:54,480
which occupies exactly 50% of this bigger container.
160
00:08:54,480 --> 00:08:55,540
All right.
161
00:08:55,540 --> 00:08:58,600
And so in the end, achieving a layout like this
162
00:08:58,600 --> 00:09:01,394
is all about thinking about these boxes
163
00:09:01,394 --> 00:09:04,240
and how we want them to be laid out
164
00:09:04,240 --> 00:09:08,610
and to be displayed in our website, right.
165
00:09:08,610 --> 00:09:11,529
So really, it's all just a matter of logically thinking
166
00:09:11,529 --> 00:09:16,529
about these boxes and to push them around until, in the end,
167
00:09:16,780 --> 00:09:19,780
they are exactly where we want them to be.
168
00:09:19,780 --> 00:09:22,040
Now let's just remove some of the line height here
169
00:09:22,040 --> 00:09:24,890
in this heading.
170
00:09:24,890 --> 00:09:26,383
Looks a little bit off.
171
00:09:29,460 --> 00:09:34,100
Let's use something really small, 1.05.
172
00:09:34,100 --> 00:09:38,550
And finally, let's get rid of all of these background colors
173
00:09:38,550 --> 00:09:40,554
so that now we can finally
174
00:09:40,554 --> 00:09:44,513
add our beautiful background image there.
175
00:09:47,130 --> 00:09:49,040
So let's see.
176
00:09:49,040 --> 00:09:51,813
And there we go, beautiful.
177
00:09:52,910 --> 00:09:56,070
So this is what we're looking for.
178
00:09:56,070 --> 00:09:59,450
So all we're missing is this background color,
179
00:09:59,450 --> 00:10:01,950
and then of course, setting this text to white,
180
00:10:01,950 --> 00:10:03,733
but that is very easy.
181
00:10:05,600 --> 00:10:09,270
So that background image should be the background
182
00:10:09,270 --> 00:10:12,527
of this entire header element, right.
183
00:10:12,527 --> 00:10:15,400
And so this is where we can now define,
184
00:10:15,400 --> 00:10:20,260
for the first time ever, the background image property.
185
00:10:20,260 --> 00:10:22,130
And now to specify the image
186
00:10:22,130 --> 00:10:27,130
we need to write URL and then open and close parenthesis.
187
00:10:27,680 --> 00:10:31,050
And then here, we need to specify the path of the image
188
00:10:31,050 --> 00:10:33,350
in relation to our current file.
189
00:10:33,350 --> 00:10:37,810
And so in this case, that is simply a hero.
190
00:10:37,810 --> 00:10:42,350
So just to right here, hero.jpg.
191
00:10:42,350 --> 00:10:44,370
And we don't even need any quotes here
192
00:10:44,370 --> 00:10:46,810
around this image path,
193
00:10:46,810 --> 00:10:50,890
so all we need is to add this and we're good.
194
00:10:50,890 --> 00:10:53,710
And you already see the image being loaded up here
195
00:10:53,710 --> 00:10:56,933
in the gutter, which means that this path is correct.
196
00:10:58,370 --> 00:11:01,230
So we will have this background image now already,
197
00:11:01,230 --> 00:11:04,483
but it will not look as expected, as you see.
198
00:11:05,370 --> 00:11:08,090
So this image is in fact huge.
199
00:11:08,090 --> 00:11:10,360
And so therefore, we only can see
200
00:11:10,360 --> 00:11:13,033
a small part of that image right now.
201
00:11:14,400 --> 00:11:16,030
Right.
202
00:11:16,030 --> 00:11:19,620
So these lights that we see here are basically,
203
00:11:19,620 --> 00:11:21,930
well, it's just this small part here
204
00:11:21,930 --> 00:11:25,370
off the website somehow, right.
205
00:11:25,370 --> 00:11:27,700
And so therefore, we now need some way
206
00:11:27,700 --> 00:11:29,533
of shrinking that image down.
207
00:11:30,770 --> 00:11:34,990
But fortunately for us, there is a nice and handy property,
208
00:11:34,990 --> 00:11:38,970
which is called the background-size.
209
00:11:38,970 --> 00:11:41,440
And here there are a couple of different options,
210
00:11:41,440 --> 00:11:44,420
and mainly those are contain and cover,
211
00:11:44,420 --> 00:11:47,033
but I usually, and I think everyone,
212
00:11:47,033 --> 00:11:49,743
most of the times just uses cover.
213
00:11:50,890 --> 00:11:53,442
And what does the value of cover here will do
214
00:11:53,442 --> 00:11:57,037
is to figure out automatically the exact size
215
00:11:57,037 --> 00:12:01,103
that the image needs to be to cover, as the name says here,
216
00:12:01,103 --> 00:12:03,800
the entire element.
217
00:12:03,800 --> 00:12:08,750
And so now as we check this out, it looks a lot better.
218
00:12:08,750 --> 00:12:10,890
And so as we resize,
219
00:12:10,890 --> 00:12:14,210
you will see that always the image covers the element,
220
00:12:14,210 --> 00:12:15,323
no matter what we do.
221
00:12:16,368 --> 00:12:17,443
All right.
222
00:12:19,580 --> 00:12:22,160
So this looks great already,
223
00:12:22,160 --> 00:12:25,160
but there is still a crucial difference here.
224
00:12:25,160 --> 00:12:27,330
And that difference is that here,
225
00:12:27,330 --> 00:12:32,330
we actually have this dark overlay over this image, right.
226
00:12:32,740 --> 00:12:36,060
So remember from one of our web design sections
227
00:12:36,060 --> 00:12:38,440
that when our image is too light,
228
00:12:38,440 --> 00:12:40,718
in order to actually make the text readable,
229
00:12:40,718 --> 00:12:43,214
we can, as one of the options,
230
00:12:43,214 --> 00:12:45,860
make the image a little bit darker.
231
00:12:45,860 --> 00:12:50,803
And so that's what this darker overlay here is all about.
232
00:12:51,750 --> 00:12:55,990
So of course, right now our text is even still gray.
233
00:12:55,990 --> 00:12:58,960
So let's make it white here in the first place.
234
00:12:58,960 --> 00:13:01,173
So we can actually see what we need to do.
235
00:13:03,980 --> 00:13:05,450
So just like this.
236
00:13:05,450 --> 00:13:09,344
And I mean, technically we could read it, right,
237
00:13:09,344 --> 00:13:11,380
but still it looks kind of off.
238
00:13:11,380 --> 00:13:14,210
There's not enough contrast here right now
239
00:13:14,210 --> 00:13:16,860
between this text and this image.
240
00:13:16,860 --> 00:13:18,520
So it's quite confusing,
241
00:13:18,520 --> 00:13:21,003
and so we need to dark and down that image.
242
00:13:21,950 --> 00:13:24,960
Now, doing that is not really trivial,
243
00:13:24,960 --> 00:13:28,760
so it is a bit harder than it might seem.
244
00:13:28,760 --> 00:13:31,820
So you might've thought that there was some simple property
245
00:13:31,820 --> 00:13:36,290
that would simply do that, but in fact, there is not.
246
00:13:36,290 --> 00:13:38,050
Instead, what we need to do
247
00:13:38,050 --> 00:13:41,630
is to basically create a stack of background images
248
00:13:41,630 --> 00:13:43,410
where the first background image
249
00:13:43,410 --> 00:13:46,830
is a gradient that is transparent.
250
00:13:46,830 --> 00:13:49,077
So that sounded a little bit confusing.
251
00:13:49,077 --> 00:13:52,223
So let me actually show you how it works.
252
00:13:52,223 --> 00:13:54,058
And actually to do this,
253
00:13:54,058 --> 00:13:56,681
let's create a gradient somewhere else,
254
00:13:56,681 --> 00:13:59,463
just so you see how the syntax works.
255
00:14:02,350 --> 00:14:06,113
So to create a gradient, we still use the background image,
256
00:14:09,470 --> 00:14:13,560
and then we use the linear gradient function like this.
257
00:14:13,560 --> 00:14:18,560
So linear-gradient, and then we can specify two colors.
258
00:14:18,760 --> 00:14:21,123
So let's say red and blue,
259
00:14:21,957 --> 00:14:26,130
okay, just to test a very simple gradient.
260
00:14:26,130 --> 00:14:30,040
And so you see, now we do have this gradient
261
00:14:30,040 --> 00:14:31,893
going from red to blue.
262
00:14:32,910 --> 00:14:35,467
Okay, so that's the very basic syntax
263
00:14:35,467 --> 00:14:37,630
of the linear gradient.
264
00:14:37,630 --> 00:14:41,170
And we can do some more stuff like changing the direction.
265
00:14:41,170 --> 00:14:43,403
For example, we can say to right,
266
00:14:44,930 --> 00:14:48,190
so as a first option here.
267
00:14:48,190 --> 00:14:50,800
I think this is how it works at least.
268
00:14:50,800 --> 00:14:52,140
And, yeah.
269
00:14:52,140 --> 00:14:55,603
So now it goes from red to blue from left to right.
270
00:14:56,600 --> 00:14:59,600
Okay, but anyway, we will explore gradients
271
00:14:59,600 --> 00:15:02,160
a little bit more in the next section,
272
00:15:02,160 --> 00:15:04,780
but I just wanted to show you how they work.
273
00:15:04,780 --> 00:15:07,380
And that's important because, as I said,
274
00:15:07,380 --> 00:15:09,350
we actually need a linear gradient
275
00:15:09,350 --> 00:15:11,333
to make a background image darker.
276
00:15:12,400 --> 00:15:14,470
So this is kind of a strange trick.
277
00:15:14,470 --> 00:15:16,360
So let me show it to you.
278
00:15:16,360 --> 00:15:18,470
So here in the same background image,
279
00:15:18,470 --> 00:15:22,340
we will now specify a linear gradient.
280
00:15:22,340 --> 00:15:27,340
And then with a comma, we basically specify a second image.
281
00:15:28,450 --> 00:15:32,050
So this is kind of a stack where this background image here,
282
00:15:32,050 --> 00:15:35,780
which is this gradient, is on top of this one.
283
00:15:35,780 --> 00:15:38,410
And we could, in fact, specify many different
284
00:15:38,410 --> 00:15:41,313
background images even, not just one or two.
285
00:15:42,260 --> 00:15:45,580
So again, this will create a stack where this one is on top,
286
00:15:45,580 --> 00:15:47,663
and this one here is on the bottom.
287
00:15:48,591 --> 00:15:52,180
But now, what colors are we actually going to use?
288
00:15:52,180 --> 00:15:55,630
Well, we want to make the image darker, right?
289
00:15:55,630 --> 00:15:58,657
And so let's start with black, so 000,
290
00:15:59,940 --> 00:16:03,560
and then the other value, let's make it also black.
291
00:16:03,560 --> 00:16:05,600
So that is the trick here,
292
00:16:05,600 --> 00:16:09,020
which is to make both colors here the same.
293
00:16:09,020 --> 00:16:11,230
But of course, we don't want absolute black
294
00:16:11,230 --> 00:16:15,410
because then we would get this, okay.
295
00:16:15,410 --> 00:16:19,920
So we want some opacity here, so some RGBA.
296
00:16:19,920 --> 00:16:24,313
So let's do that by clicking here on the title again.
297
00:16:26,000 --> 00:16:29,800
And so, we already had it, actually.
298
00:16:29,800 --> 00:16:33,203
So let's put this here, like to 0.6,
299
00:16:35,720 --> 00:16:40,720
and then let's do the same here for the second color.
300
00:16:42,480 --> 00:16:47,260
And now we should actually get a usable result.
301
00:16:47,260 --> 00:16:49,690
Well, not quite, actually.
302
00:16:49,690 --> 00:16:51,133
Let's go back here.
303
00:16:51,133 --> 00:16:54,933
That's because I did not delete the hash here,
304
00:16:56,710 --> 00:16:58,780
but here we go.
305
00:16:58,780 --> 00:17:02,030
So that's beautiful, right?
306
00:17:02,030 --> 00:17:07,030
And, yeah, it is the same color here all over the image,
307
00:17:07,830 --> 00:17:10,080
again, because we made the gradient
308
00:17:10,080 --> 00:17:12,236
go from one color to the second one,
309
00:17:12,236 --> 00:17:14,950
which are both exactly the same.
310
00:17:14,950 --> 00:17:17,620
But of course, it wouldn't have to be that way.
311
00:17:17,620 --> 00:17:20,803
We can specify some other,
312
00:17:21,850 --> 00:17:23,920
let's say just some random colors here,
313
00:17:23,920 --> 00:17:25,970
just to see that in this case, of course,
314
00:17:25,970 --> 00:17:30,970
we could go from black to this kind of blue color here.
315
00:17:31,710 --> 00:17:32,543
Right.
316
00:17:32,543 --> 00:17:34,730
But of course, we don't want that.
317
00:17:34,730 --> 00:17:36,212
We want them to be the same,
318
00:17:36,212 --> 00:17:40,441
but let's just use some kind of a gray here.
319
00:17:40,441 --> 00:17:44,483
It looks a little bit better than just pure black usually.
320
00:17:47,150 --> 00:17:50,135
But again, that is a design decision you have to take.
321
00:17:50,135 --> 00:17:52,469
So of course, you can use pure black,
322
00:17:52,469 --> 00:17:56,280
but I think using some shade of gray here
323
00:17:56,280 --> 00:17:57,800
looks a little bit better.
324
00:17:57,800 --> 00:18:01,110
So it gives us this kind of softer touch here.
325
00:18:01,110 --> 00:18:05,043
And so I think now we actually have the exact same design
326
00:18:05,043 --> 00:18:07,970
as in our final result.
327
00:18:07,970 --> 00:18:10,440
There's just some spacing here going on.
328
00:18:10,440 --> 00:18:12,340
So let's add that.
329
00:18:12,340 --> 00:18:16,978
So that's in the navigation, so here.
330
00:18:16,978 --> 00:18:20,203
And let me actually show you how to not do it.
331
00:18:21,050 --> 00:18:25,757
So let's say margin-top 32 pixels.
332
00:18:29,530 --> 00:18:32,763
So why do you think that is not going to work as intended?
333
00:18:34,970 --> 00:18:38,214
And well, nothing happened here.
334
00:18:38,214 --> 00:18:40,943
Let's inspect why that is.
335
00:18:43,270 --> 00:18:48,270
So here we have our a margin-top of 32 pixels,
336
00:18:49,020 --> 00:18:51,150
but it is actually crossed out,
337
00:18:51,150 --> 00:18:53,670
and that's because from the container,
338
00:18:53,670 --> 00:18:56,790
we get margin top and bottom of zero.
339
00:18:56,790 --> 00:18:59,660
And so remember our priorities.
340
00:18:59,660 --> 00:19:02,618
So a class selector has more priority
341
00:19:02,618 --> 00:19:05,220
than a simple element selector,
342
00:19:05,220 --> 00:19:09,063
and so that's why this one here overrides this one.
343
00:19:10,110 --> 00:19:12,740
But here in the developer tools,
344
00:19:12,740 --> 00:19:15,964
we can actually also set styles right here.
345
00:19:15,964 --> 00:19:20,130
And so this element style will basically set them
346
00:19:20,130 --> 00:19:22,300
right here as inline styles.
347
00:19:22,300 --> 00:19:25,767
And so remember that those have an even higher priority.
348
00:19:25,767 --> 00:19:30,767
So just to experiment, so margin-top 32 pixels.
349
00:19:34,810 --> 00:19:36,920
So you see now it's set that here,
350
00:19:36,920 --> 00:19:39,283
and it's now overriding that zero.
351
00:19:40,490 --> 00:19:42,260
Now I mentioned that I wanted to show you
352
00:19:42,260 --> 00:19:43,810
why this doesn't work.
353
00:19:43,810 --> 00:19:46,557
And the reason is that now this actually will create
354
00:19:46,557 --> 00:19:51,191
an empty space outside of the box, right.
355
00:19:51,191 --> 00:19:54,250
And so that will then therefore create
356
00:19:54,250 --> 00:19:56,373
this white space here on top.
357
00:19:57,400 --> 00:19:59,980
So that's obviously not what we want,
358
00:19:59,980 --> 00:20:03,803
so we want to go with padding instead.
359
00:20:04,930 --> 00:20:06,850
So let's see.
360
00:20:06,850 --> 00:20:08,163
And there we go.
361
00:20:09,348 --> 00:20:13,200
And with that, we actually finished this header component.
362
00:20:13,200 --> 00:20:16,660
So a lot of new CSS we learned here,
363
00:20:16,660 --> 00:20:20,060
and in particular, we learned how to set
364
00:20:20,060 --> 00:20:21,495
this background image here,
365
00:20:21,495 --> 00:20:24,360
we learned about the background size,
366
00:20:24,360 --> 00:20:28,050
And also we learned about this new VH unit.
367
00:20:28,050 --> 00:20:30,828
And also, and probably even more importantly,
368
00:20:30,828 --> 00:20:33,419
we kept thinking about how to achieve
369
00:20:33,419 --> 00:20:37,093
the layouts that we wanted using the code tools
370
00:20:37,093 --> 00:20:39,200
that we have at this point.
371
00:20:39,200 --> 00:20:41,450
So teaching you that is probably
372
00:20:41,450 --> 00:20:43,590
my most important goal here
373
00:20:43,590 --> 00:20:46,800
because looking at properties is very simple,
374
00:20:46,800 --> 00:20:51,130
but learning how to think about how to create a layout
375
00:20:51,130 --> 00:20:53,627
exactly like this with all the properties
376
00:20:53,627 --> 00:20:55,790
that we would like it to have
377
00:20:55,790 --> 00:20:59,150
is not so easy to look up on the web.
378
00:20:59,150 --> 00:21:01,097
And so I hope that with all these exercises
379
00:21:01,097 --> 00:21:03,550
and all these small projects
380
00:21:03,550 --> 00:21:06,797
you are starting to get better and better at that.
381
00:21:06,797 --> 00:21:10,630
But anyway, that wraps up this small mini project.
382
00:21:10,630 --> 00:21:13,380
And so now there's only one more component
383
00:21:13,380 --> 00:21:17,090
or one more layout to build in this section.
384
00:21:17,090 --> 00:21:19,313
And so I hope to see you there soon.
28483
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.