Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,140 --> 00:00:03,500
Hey there, and welcome back
2
00:00:03,500 --> 00:00:05,870
to writing some more code.
3
00:00:05,870 --> 00:00:09,350
And this lecture is going to be really exciting
4
00:00:09,350 --> 00:00:11,480
because in this and the next one,
5
00:00:11,480 --> 00:00:14,610
we will build a beautiful hero section
6
00:00:14,610 --> 00:00:18,500
and learn a ton of new CSS along the way.
7
00:00:18,500 --> 00:00:20,553
So let's get started.
8
00:00:22,100 --> 00:00:25,390
And this is the hero section that we're going to build
9
00:00:25,390 --> 00:00:27,140
in this lecture.
10
00:00:27,140 --> 00:00:30,800
And it actually has the content of the Omnifood Project
11
00:00:30,800 --> 00:00:33,250
that we will start very soon.
12
00:00:33,250 --> 00:00:36,840
So this heading here, and this description, and this button
13
00:00:36,840 --> 00:00:38,940
are exactly the ones that we will find
14
00:00:38,940 --> 00:00:40,730
also in our Omnifood section
15
00:00:41,690 --> 00:00:44,410
or actually, our Omnifood Project.
16
00:00:44,410 --> 00:00:47,840
So you see here this beautiful background image,
17
00:00:47,840 --> 00:00:51,490
which spans all across this viewport.
18
00:00:51,490 --> 00:00:55,383
So it has exactly the height and the width of the viewport.
19
00:00:56,220 --> 00:00:57,980
So if we change this here,
20
00:00:57,980 --> 00:01:00,420
you can see the image changing,
21
00:01:00,420 --> 00:01:01,440
right?
22
00:01:01,440 --> 00:01:03,520
And we can even of course,
23
00:01:03,520 --> 00:01:05,510
change the entire window
24
00:01:05,510 --> 00:01:09,370
and noticed how the text always stay centered.
25
00:01:09,370 --> 00:01:11,990
So basically this entire block here,
26
00:01:11,990 --> 00:01:15,020
it always stay centered vertically.
27
00:01:15,020 --> 00:01:17,360
So even in the extreme case,
28
00:01:17,360 --> 00:01:19,050
going over
29
00:01:19,050 --> 00:01:20,790
that navigation.
30
00:01:20,790 --> 00:01:23,570
So basically this bar here,
31
00:01:23,570 --> 00:01:26,150
so this logo and the navigation, of course,
32
00:01:26,150 --> 00:01:27,560
don't look real,
33
00:01:27,560 --> 00:01:31,060
but we will do that in our Omnifood Project.
34
00:01:31,060 --> 00:01:33,410
Now I'm only interested here basically
35
00:01:33,410 --> 00:01:35,790
in the rest of the hero section.
36
00:01:35,790 --> 00:01:37,900
So having this background image
37
00:01:37,900 --> 00:01:41,090
and having then this nice block of text here,
38
00:01:41,090 --> 00:01:45,000
and all basically filling the entire browser
39
00:01:45,000 --> 00:01:48,700
and especially, filling here the entire height.
40
00:01:48,700 --> 00:01:52,120
So I think that this is an exciting small project,
41
00:01:52,120 --> 00:01:53,993
and so let's get started now.
42
00:01:55,030 --> 00:01:57,130
And since we now actually need
43
00:01:57,130 --> 00:01:59,550
the entire size of the browser,
44
00:01:59,550 --> 00:02:04,350
let me actually put this here on another desktop on the Mac.
45
00:02:04,350 --> 00:02:05,820
And if you're on windows,
46
00:02:05,820 --> 00:02:08,233
you can just keep switching between the windows.
47
00:02:09,400 --> 00:02:11,510
Let's make this one here big
48
00:02:11,510 --> 00:02:14,623
and also create here a new component.
49
00:02:15,720 --> 00:02:17,880
So the hero.html
50
00:02:20,750 --> 00:02:22,810
and this one we will actually not copy
51
00:02:22,810 --> 00:02:24,290
from the other component
52
00:02:24,290 --> 00:02:27,170
because there are some major differences,
53
00:02:27,170 --> 00:02:31,740
but we will also scaffold very easily our HTML.
54
00:02:31,740 --> 00:02:32,900
So again,
55
00:02:32,900 --> 00:02:34,670
just write the exclamation mark
56
00:02:34,670 --> 00:02:36,450
and then hit Tab
57
00:02:36,450 --> 00:02:38,073
and there is our HTML.
58
00:02:40,570 --> 00:02:42,370
Let's just say it's the Omnifood
59
00:02:44,750 --> 00:02:45,943
Hero Section.
60
00:02:46,810 --> 00:02:48,070
Okay.
61
00:02:48,070 --> 00:02:49,390
Then here inside of the head,
62
00:02:49,390 --> 00:02:51,930
we will also have the style
63
00:02:51,930 --> 00:02:55,130
so that we don't need two different files.
64
00:02:55,130 --> 00:02:58,930
And now here in the body, let's create our hero section.
65
00:02:58,930 --> 00:03:01,283
And for that, we will use the header element.
66
00:03:04,340 --> 00:03:05,300
All right.
67
00:03:05,300 --> 00:03:09,270
So remember that the header element is the semantic element
68
00:03:09,270 --> 00:03:12,453
for basically the introduction of the website.
69
00:03:13,450 --> 00:03:15,963
And so that is, essentially, what this is.
70
00:03:16,820 --> 00:03:20,320
Now also, I didn't show you that, then below this
71
00:03:20,320 --> 00:03:24,080
we have some other section with just some random text,
72
00:03:24,080 --> 00:03:26,520
just so we can exactly see
73
00:03:26,520 --> 00:03:31,057
that this header has exactly the height of the viewport.
74
00:03:32,260 --> 00:03:36,980
And so that will then simply be a section element,
75
00:03:36,980 --> 00:03:39,730
which remember, is exactly that,
76
00:03:39,730 --> 00:03:42,163
so just a section of the page.
77
00:03:43,080 --> 00:03:44,910
So then here inside of the header,
78
00:03:44,910 --> 00:03:47,560
we will have a 'nav' element.
79
00:03:47,560 --> 00:03:48,393
And then here,
80
00:03:48,393 --> 00:03:50,890
we would typically include some logo
81
00:03:50,890 --> 00:03:53,330
and some actual navigation links.
82
00:03:53,330 --> 00:03:55,520
But here I will simply add some div,
83
00:03:55,520 --> 00:03:57,263
which then says "logo"
84
00:03:58,100 --> 00:04:01,797
and another div which says "navigation".
85
00:04:05,470 --> 00:04:06,570
Okay.
86
00:04:06,570 --> 00:04:08,430
So that is that first box.
87
00:04:08,430 --> 00:04:11,170
And now here is basically that big box
88
00:04:11,170 --> 00:04:13,040
which will contain all of the content
89
00:04:14,120 --> 00:04:17,320
and notice how I'm not using any class names here.
90
00:04:17,320 --> 00:04:18,910
So I want to do that a bit later
91
00:04:18,910 --> 00:04:21,630
as we start writing the CSS together.
92
00:04:21,630 --> 00:04:22,640
So basically,
93
00:04:22,640 --> 00:04:25,350
so I can explain you how we built a thing like this
94
00:04:25,350 --> 00:04:26,930
Step-by-step
95
00:04:26,930 --> 00:04:28,260
completely from scratch,
96
00:04:28,260 --> 00:04:31,453
without assuming any of the class names in the beginning.
97
00:04:32,700 --> 00:04:36,160
But anyway, let's now write our actual content here.
98
00:04:36,160 --> 00:04:37,760
So, "A healthy
99
00:04:37,760 --> 00:04:38,940
meal
100
00:04:38,940 --> 00:04:39,773
delivered
101
00:04:40,690 --> 00:04:42,440
to your door
102
00:04:42,440 --> 00:04:43,500
every
103
00:04:43,500 --> 00:04:44,333
single day"
104
00:04:46,410 --> 00:04:48,450
Next, there is some paragraph
105
00:04:48,450 --> 00:04:51,620
and you can just write some blind text here if you want.
106
00:04:51,620 --> 00:04:53,770
But in this case, in the very beginning,
107
00:04:53,770 --> 00:04:55,510
I like to actually have some
108
00:04:56,640 --> 00:04:57,653
actual content.
109
00:04:58,550 --> 00:05:01,423
So to make it a little bit more real looking.
110
00:05:02,270 --> 00:05:06,113
So, "The 360-days-per-year food subscription,
111
00:05:10,400 --> 00:05:11,350
that will
112
00:05:11,350 --> 00:05:12,550
make
113
00:05:12,550 --> 00:05:13,850
you eat
114
00:05:13,850 --> 00:05:14,683
healthy
115
00:05:15,540 --> 00:05:16,373
again.
116
00:05:17,380 --> 00:05:18,930
Tailored
117
00:05:18,930 --> 00:05:19,860
to
118
00:05:19,860 --> 00:05:20,693
your
119
00:05:21,530 --> 00:05:23,290
personal tastes
120
00:05:23,290 --> 00:05:24,582
and
121
00:05:24,582 --> 00:05:26,320
nutritional
122
00:05:26,320 --> 00:05:27,217
needs."
123
00:05:28,080 --> 00:05:29,120
Okay.
124
00:05:29,120 --> 00:05:31,350
And then we have some kind of button there
125
00:05:31,350 --> 00:05:33,520
but that button is actually a link
126
00:05:33,520 --> 00:05:35,870
because it leads somewhere.
127
00:05:35,870 --> 00:05:39,410
But let's of course give it an empty H-ref,
128
00:05:39,410 --> 00:05:40,800
just like usually.
129
00:05:40,800 --> 00:05:43,800
and here we can actually already put our class,
130
00:05:43,800 --> 00:05:45,677
which is, as usual, "button".
131
00:05:46,810 --> 00:05:49,740
So "Start eating well".
132
00:05:49,740 --> 00:05:50,650
Okay.
133
00:05:50,650 --> 00:05:52,930
And for now that is it.
134
00:05:52,930 --> 00:05:55,250
And now, inside of the section,
135
00:05:55,250 --> 00:05:59,920
we will want to then center the entire content here.
136
00:05:59,920 --> 00:06:01,993
So let's give ourselves another box.
137
00:06:03,900 --> 00:06:05,570
And then in there,
138
00:06:05,570 --> 00:06:09,080
some H2 element, for example.
139
00:06:09,080 --> 00:06:12,767
So "Some, I don't know, random handy heading",
140
00:06:13,710 --> 00:06:15,040
and then some paragraph.
141
00:06:15,040 --> 00:06:17,067
And here we can now use 'lorem',
142
00:06:18,350 --> 00:06:19,963
maybe even twice.
143
00:06:21,900 --> 00:06:23,490
Okay.
144
00:06:23,490 --> 00:06:27,293
So let's take a look at our result for now.
145
00:06:29,010 --> 00:06:31,230
So once again, we need to now go back
146
00:06:32,950 --> 00:06:34,713
or just remove this part here.
147
00:06:36,210 --> 00:06:37,953
And here it is, the hero.
148
00:06:38,800 --> 00:06:40,890
And so indeed, our content here
149
00:06:40,890 --> 00:06:44,030
without any styling whatsoever.
150
00:06:44,030 --> 00:06:47,090
And so let's actually start with that styling
151
00:06:47,090 --> 00:06:49,933
and I will now select another font from Google Fonts.
152
00:06:52,710 --> 00:06:57,610
And the one that we are going for is called Rubik.
153
00:06:57,610 --> 00:07:00,700
And I'll explain more about why this is the choice
154
00:07:00,700 --> 00:07:01,970
of our typeface
155
00:07:03,730 --> 00:07:06,833
when we actually build the project in the next section.
156
00:07:07,960 --> 00:07:11,423
So, 4-, maybe 5-, and 700.
157
00:07:13,000 --> 00:07:14,400
Okay.
158
00:07:14,400 --> 00:07:17,340
So as always just select these different styles
159
00:07:17,340 --> 00:07:21,030
of different font weights, basically.
160
00:07:21,030 --> 00:07:23,150
And then here is that summary.
161
00:07:23,150 --> 00:07:25,990
So we selected regular, medium and bold.
162
00:07:25,990 --> 00:07:28,390
And then all we have to do is to
163
00:07:29,770 --> 00:07:34,770
copy this link that we now need to include in our HTML
164
00:07:35,150 --> 00:07:36,083
in the very top.
165
00:07:37,720 --> 00:07:40,860
So it needs to be before our own style.
166
00:07:40,860 --> 00:07:42,703
Let's actually put that here.
167
00:07:45,320 --> 00:07:46,153
Okay.
168
00:07:47,640 --> 00:07:49,870
And now in our HTML,
169
00:07:49,870 --> 00:07:50,833
we can say,
170
00:07:51,880 --> 00:07:52,970
font-family
171
00:07:55,010 --> 00:07:58,260
and then we set it to Rubik.
172
00:07:58,260 --> 00:08:00,980
And then if that is somehow not available,
173
00:08:00,980 --> 00:08:02,640
as a second option,
174
00:08:02,640 --> 00:08:06,413
we then want just the predefined sans-serif typeface.
175
00:08:07,270 --> 00:08:08,240
Okay.
176
00:08:08,240 --> 00:08:09,920
And as the text color,
177
00:08:09,920 --> 00:08:12,480
let's just use some gray here:
178
00:08:12,480 --> 00:08:13,643
4-4-4.
179
00:08:14,760 --> 00:08:16,420
Okay.
180
00:08:16,420 --> 00:08:18,870
So that should look,
181
00:08:18,870 --> 00:08:21,360
yeah, a little bit better already.
182
00:08:21,360 --> 00:08:22,220
Okay.
183
00:08:22,220 --> 00:08:26,420
And now let's just create basically the visual styling here.
184
00:08:26,420 --> 00:08:28,430
So make this text a little bit bigger
185
00:08:28,430 --> 00:08:30,750
and also put them side by side.
186
00:08:30,750 --> 00:08:33,450
And of course styling all of this text here,
187
00:08:33,450 --> 00:08:35,083
including this button.
188
00:08:36,459 --> 00:08:38,370
Okay.
189
00:08:38,370 --> 00:08:40,313
So starting with the navigation,
190
00:08:45,240 --> 00:08:48,210
let's set a font size of 20 pixels
191
00:08:49,590 --> 00:08:51,613
and make it bold as well.
192
00:08:54,160 --> 00:08:55,730
And, actually, let's
193
00:08:55,730 --> 00:08:58,960
select the actual number, 700,
194
00:08:58,960 --> 00:09:00,830
that we loaded here.
195
00:09:00,830 --> 00:09:01,663
Right?
196
00:09:01,663 --> 00:09:04,170
So these are the actual font weights
197
00:09:05,420 --> 00:09:07,760
and then, to put them side by side of course,
198
00:09:07,760 --> 00:09:08,973
we use "display"
199
00:09:09,930 --> 00:09:11,410
set to "flex"
200
00:09:11,410 --> 00:09:14,910
and then the trick to push each of them to one of the sides,
201
00:09:14,910 --> 00:09:16,140
remember,
202
00:09:16,140 --> 00:09:20,983
is, justify content to space-between.
203
00:09:22,550 --> 00:09:23,383
Okay,
204
00:09:24,860 --> 00:09:26,140
Beautiful.
205
00:09:26,140 --> 00:09:27,740
So there we go.
206
00:09:27,740 --> 00:09:29,500
That looks great!
207
00:09:29,500 --> 00:09:32,313
And now let's work with our h1,
208
00:09:36,060 --> 00:09:40,310
so let's make it quite big at 52 pixels.
209
00:09:40,310 --> 00:09:43,190
And this is actually, once again, one of the values of,
210
00:09:43,190 --> 00:09:45,380
or a type scale.
211
00:09:45,380 --> 00:09:47,070
So we can look that up
212
00:09:47,070 --> 00:09:48,970
somewhere here, for example.
213
00:09:48,970 --> 00:09:51,020
And so here is that 52.
214
00:09:51,020 --> 00:09:53,110
And again, I'm not going to
215
00:09:54,050 --> 00:09:57,160
choose now multiple to show you how it works,
216
00:09:57,160 --> 00:09:59,223
because that will take up too much time.
217
00:10:00,100 --> 00:10:00,933
All right.
218
00:10:01,980 --> 00:10:04,230
Then just some margin on the bottom,
219
00:10:04,230 --> 00:10:06,533
let's say 32 pixels.
220
00:10:08,000 --> 00:10:10,080
And then let's also style this paragraph
221
00:10:11,470 --> 00:10:13,660
and this will then also style that one,
222
00:10:13,660 --> 00:10:16,053
which is not really relevant anyway.
223
00:10:17,140 --> 00:10:20,253
So font size of 20 pixels.
224
00:10:21,330 --> 00:10:22,890
So you see that usually I start
225
00:10:22,890 --> 00:10:24,793
with these visual text styles.
226
00:10:26,610 --> 00:10:28,700
Let's also add some line height of 1.6
227
00:10:30,836 --> 00:10:32,580
and then some margin to the bottom,
228
00:10:32,580 --> 00:10:35,983
because remember that afterwards, comes the button.
229
00:10:38,890 --> 00:10:39,723
All right.
230
00:10:40,940 --> 00:10:43,303
So let's take a quick look at what we have.
231
00:10:45,120 --> 00:10:46,080
Great.
232
00:10:46,080 --> 00:10:47,810
That looks very nice.
233
00:10:47,810 --> 00:10:52,050
And now again, making this button look like this.
234
00:10:52,050 --> 00:10:54,470
So these slightly rounded corners
235
00:10:54,470 --> 00:10:56,663
and this beautiful orange color.
236
00:10:58,700 --> 00:11:00,743
So that is called "the button"
237
00:11:02,320 --> 00:11:03,680
And as always,
238
00:11:03,680 --> 00:11:06,390
we need to style the "visited" state
239
00:11:06,390 --> 00:11:10,293
and actually first even, the "link" state.
240
00:11:12,070 --> 00:11:13,553
So always in this order.
241
00:11:15,800 --> 00:11:18,963
So let's give it a font size of 20 pixels,
242
00:11:21,520 --> 00:11:23,210
a font weight,
243
00:11:23,210 --> 00:11:25,520
we selected 600 as well.
244
00:11:25,520 --> 00:11:27,150
Actually we did not.
245
00:11:27,150 --> 00:11:28,260
So instead of 500,
246
00:11:28,260 --> 00:11:31,240
let's actually select 600.
247
00:11:31,240 --> 00:11:32,470
So to make it bold,
248
00:11:32,470 --> 00:11:34,173
but not quite as bold
249
00:11:34,173 --> 00:11:36,203
because that looks strange a little bit.
250
00:11:37,610 --> 00:11:40,683
So 600 is just nice for buttons usually.
251
00:11:43,760 --> 00:11:45,630
Then that background color,
252
00:11:45,630 --> 00:11:48,480
and here I'm just going to give you the hexadecimal code:
253
00:11:50,110 --> 00:11:53,110
so E-6-7-E-2-2.
254
00:11:54,450 --> 00:11:55,600
All right.
255
00:11:55,600 --> 00:11:58,200
And the color then of course needs to be white,
256
00:11:58,200 --> 00:12:00,300
otherwise we're not going to see anything.
257
00:12:01,730 --> 00:12:04,303
And we also need to get rid of the underline.
258
00:12:05,650 --> 00:12:08,673
So, text-decoration:
259
00:12:09,510 --> 00:12:10,343
none.
260
00:12:11,550 --> 00:12:14,673
So part of the button should be done now.
261
00:12:16,290 --> 00:12:17,123
All right.
262
00:12:17,123 --> 00:12:19,370
But now, of course, we need some spacing around it
263
00:12:19,370 --> 00:12:21,010
and the rounded corners.
264
00:12:22,770 --> 00:12:25,170
So, for that we need some padding
265
00:12:25,170 --> 00:12:27,290
and if we want to apply padding,
266
00:12:27,290 --> 00:12:29,510
then we should make this an inline-block
267
00:12:29,510 --> 00:12:33,323
and not just an inline-element as it is by default.
268
00:12:34,890 --> 00:12:36,850
So, inline-block.
269
00:12:36,850 --> 00:12:37,683
And so this is
270
00:12:38,730 --> 00:12:41,993
hopefully starting to get routine at this point.
271
00:12:43,200 --> 00:12:44,770
So, 16 pixels
272
00:12:44,770 --> 00:12:48,560
and as usual, I like to give left and right
273
00:12:48,560 --> 00:12:51,070
the double as top and bottom.
274
00:12:51,070 --> 00:12:53,250
So this one is the value on top and bottom
275
00:12:53,250 --> 00:12:55,653
and this, on left and right side.
276
00:12:56,620 --> 00:12:57,880
Remember.
277
00:12:57,880 --> 00:13:01,300
And so now border-radius:
278
00:13:01,300 --> 00:13:04,023
and here let's say nine pixels,
279
00:13:05,130 --> 00:13:06,740
and
280
00:13:06,740 --> 00:13:07,573
there we go.
281
00:13:08,800 --> 00:13:10,840
So that looks very beautiful.
282
00:13:10,840 --> 00:13:13,930
And so all that we need to style is this h2 here
283
00:13:13,930 --> 00:13:15,190
and
284
00:13:15,190 --> 00:13:18,223
maybe add some padding to this entire section as well.
285
00:13:20,350 --> 00:13:21,480
So, h2
286
00:13:26,630 --> 00:13:28,490
44 pixels
287
00:13:28,490 --> 00:13:30,520
which I think is the
288
00:13:30,520 --> 00:13:32,690
value below 52.
289
00:13:32,690 --> 00:13:33,523
Right.
290
00:13:38,610 --> 00:13:42,573
And some margin to the bottom of 48 pixels.
291
00:13:43,890 --> 00:13:44,723
All right.
292
00:13:44,723 --> 00:13:48,163
And finally add some padding to the section.
293
00:13:49,900 --> 00:13:53,440
So, 96 top and bottom,
294
00:13:53,440 --> 00:13:56,930
and the sides don't need any padding at all.
295
00:13:56,930 --> 00:13:57,800
Okay.
296
00:13:57,800 --> 00:13:59,950
And I'm doing this all quite fast,
297
00:13:59,950 --> 00:14:02,100
but once we actually start designing
298
00:14:02,100 --> 00:14:05,260
and building the Omnifood Project in the next section,
299
00:14:05,260 --> 00:14:07,500
then I will go over these design decisions
300
00:14:07,500 --> 00:14:09,190
a little bit better.
301
00:14:09,190 --> 00:14:11,770
But anyway, let's now compare this a little bit
302
00:14:11,770 --> 00:14:13,483
to this one here.
303
00:14:14,340 --> 00:14:17,410
And the first thing that we notice immediately is that
304
00:14:17,410 --> 00:14:19,993
all of these boxes are, kind of, centered.
305
00:14:21,050 --> 00:14:22,840
So this one here
306
00:14:22,840 --> 00:14:24,420
and all of this here,
307
00:14:24,420 --> 00:14:28,080
and also, in a way, this box here,
308
00:14:28,080 --> 00:14:29,930
I mean, it doesn't really look centered.
309
00:14:29,930 --> 00:14:33,110
It looks more like it's aligned here.
310
00:14:33,110 --> 00:14:36,680
But still, if we change the width here,
311
00:14:36,680 --> 00:14:39,323
then you see that still it kind of, is centered.
312
00:14:40,500 --> 00:14:43,077
So that's what I mean with "centered".
313
00:14:43,990 --> 00:14:46,060
And so let's now create
314
00:14:46,060 --> 00:14:49,623
a class which will take care of only doing that.
315
00:14:50,860 --> 00:14:55,430
So we could, of course, add now the styling of this.
316
00:14:55,430 --> 00:14:59,610
So, margin: zero and auto.
317
00:14:59,610 --> 00:15:00,443
right?
318
00:15:00,443 --> 00:15:03,910
But then we would have to add that to every single element.
319
00:15:03,910 --> 00:15:08,710
So every single box that we want centered in the browser.
320
00:15:08,710 --> 00:15:10,183
But we don't want to do that.
321
00:15:11,030 --> 00:15:14,570
So for that, we can create something like an utility class
322
00:15:15,460 --> 00:15:18,210
and then simply add that class to all the elements
323
00:15:18,210 --> 00:15:20,003
that we do want centered.
324
00:15:21,430 --> 00:15:26,117
So let's add that here and I'm going to call it "container",
325
00:15:27,050 --> 00:15:29,090
so that's a pretty common name,
326
00:15:29,090 --> 00:15:31,800
and then I'm adding that property here.
327
00:15:31,800 --> 00:15:33,580
And so now in our HTML,
328
00:15:33,580 --> 00:15:35,680
we can add that class
329
00:15:35,680 --> 00:15:36,513
here
330
00:15:38,810 --> 00:15:39,643
and here
331
00:15:42,360 --> 00:15:46,573
and also to this div here inside of the section.
332
00:15:50,260 --> 00:15:51,420
All right.
333
00:15:51,420 --> 00:15:54,750
So now this section here itself is not centered,
334
00:15:54,750 --> 00:15:57,503
but then this div is centered inside of it.
335
00:15:59,060 --> 00:16:02,440
And this, again, is a pretty normal technique.
336
00:16:02,440 --> 00:16:05,470
Now we could have centered the entire section here
337
00:16:05,470 --> 00:16:07,360
and also the entire header,
338
00:16:07,360 --> 00:16:11,060
but we actually do want these to go from side to side
339
00:16:11,060 --> 00:16:12,580
of the viewport.
340
00:16:12,580 --> 00:16:13,860
In this, case of the header,
341
00:16:13,860 --> 00:16:17,210
because we later want to give it a background image,
342
00:16:17,210 --> 00:16:19,590
and well, in case of the section,
343
00:16:19,590 --> 00:16:23,040
because imagine that it had some background color,
344
00:16:23,040 --> 00:16:23,873
for example.
345
00:16:26,080 --> 00:16:28,430
Now, actually there is one thing missing here
346
00:16:28,430 --> 00:16:31,010
because remember that we always need to specify
347
00:16:31,010 --> 00:16:33,920
a fixed with for the container.
348
00:16:33,920 --> 00:16:36,973
So for the element on which we use this trick.
349
00:16:39,110 --> 00:16:41,450
So let's say that we want all of these here
350
00:16:41,450 --> 00:16:44,960
to be 1200 pixels wide.
351
00:16:44,960 --> 00:16:47,030
And so now they will indeed be centered
352
00:16:48,720 --> 00:16:50,563
And, there we go.
353
00:16:51,720 --> 00:16:53,130
Let's see.
354
00:16:53,130 --> 00:16:56,110
Yeah, that works just nice.
355
00:16:56,110 --> 00:16:59,820
And now, as I was saying with the background colors
356
00:16:59,820 --> 00:17:01,380
and the background images,
357
00:17:01,380 --> 00:17:03,800
let's actually now add some colors
358
00:17:03,800 --> 00:17:06,793
so that we can see what I just mentioned.
359
00:17:08,380 --> 00:17:13,380
So to the nav, let's add a background color green,
360
00:17:16,490 --> 00:17:19,023
Then let's see what else we have here.
361
00:17:21,570 --> 00:17:23,080
Well, well the container,
362
00:17:23,080 --> 00:17:26,220
we actually don't want to give it a background color
363
00:17:26,220 --> 00:17:29,370
because then all of them would get the same one.
364
00:17:29,370 --> 00:17:32,433
And so, for now, let's just add one here to this section.
365
00:17:37,560 --> 00:17:40,620
And here let's add this very light gray that I like to use,
366
00:17:40,620 --> 00:17:43,563
which is F-7-F-7-F-7.
367
00:17:44,870 --> 00:17:45,703
Right.
368
00:17:45,703 --> 00:17:49,383
And actually let's shortly add a color to the container:
369
00:17:51,560 --> 00:17:52,393
red.
370
00:17:53,810 --> 00:17:55,640
Okay.
371
00:17:55,640 --> 00:17:57,860
And so now, here is what I meant
372
00:17:57,860 --> 00:18:00,730
so that we have now this content here centered
373
00:18:00,730 --> 00:18:02,730
and not the entire section,
374
00:18:02,730 --> 00:18:03,950
because to the section,
375
00:18:03,950 --> 00:18:07,500
we do actually want to apply this background image.
376
00:18:07,500 --> 00:18:10,000
And if we centered the entire section,
377
00:18:10,000 --> 00:18:12,710
well, then we couldn't give it any background color
378
00:18:12,710 --> 00:18:14,000
around it.
379
00:18:14,000 --> 00:18:16,670
So not some background color that would go all the way
380
00:18:16,670 --> 00:18:18,253
from the left to the right.
381
00:18:19,150 --> 00:18:22,870
Now, I see that we do have some margins here,
382
00:18:22,870 --> 00:18:25,160
like, on the sides of the page,
383
00:18:25,160 --> 00:18:30,083
and that's because we didn't do our general reset here.
384
00:18:30,960 --> 00:18:32,800
I forgot that somehow,
385
00:18:32,800 --> 00:18:36,120
but this is something that we must always do.
386
00:18:36,120 --> 00:18:41,120
So by default setting all margins and all paddings to zero,
387
00:18:41,440 --> 00:18:44,810
and also use the alternative box model.
388
00:18:44,810 --> 00:18:49,113
So by using box-sizing set to border-box.
389
00:18:50,140 --> 00:18:51,410
Great.
390
00:18:51,410 --> 00:18:53,610
So that's better.
391
00:18:53,610 --> 00:18:56,190
And so now, let's actually do that thing
392
00:18:56,190 --> 00:19:00,340
where we make the header the entire height of the viewport.
393
00:19:00,340 --> 00:19:01,620
So all of this.
394
00:19:01,620 --> 00:19:03,970
Because that's actually not very hard.
395
00:19:03,970 --> 00:19:06,223
And so we can do that right away.
396
00:19:07,740 --> 00:19:11,480
Now the navigation here somehow is not green.
397
00:19:11,480 --> 00:19:14,680
Ah, but sure, that's because we gave all the containers
398
00:19:14,680 --> 00:19:16,363
the red color.
399
00:19:17,240 --> 00:19:18,933
So let's remove that.
400
00:19:19,920 --> 00:19:21,230
Right.
401
00:19:21,230 --> 00:19:25,233
And let's now add some styles to the header element.
402
00:19:26,370 --> 00:19:28,280
So to start, let's just make it green
403
00:19:30,160 --> 00:19:32,090
or some other background color,
404
00:19:32,090 --> 00:19:33,753
let's say orange-red.
405
00:19:35,860 --> 00:19:38,623
So before we make it 100% tall.
406
00:19:39,720 --> 00:19:41,170
Okay.
407
00:19:41,170 --> 00:19:43,060
So that's what it looks like now.
408
00:19:43,060 --> 00:19:45,733
But now it's time to do what I just mentioned.
409
00:19:47,520 --> 00:19:48,353
So,
410
00:19:49,810 --> 00:19:52,140
we want to set the height of it,
411
00:19:52,140 --> 00:19:55,970
but now we can actually not set 100%.
412
00:19:55,970 --> 00:20:00,040
So we cannot do this because this will simply not work.
413
00:20:00,040 --> 00:20:01,970
Instead, what we need to do
414
00:20:01,970 --> 00:20:05,670
is to use a new unit that we have never talked about.
415
00:20:05,670 --> 00:20:09,550
And that unit is called 'viewport height'.
416
00:20:09,550 --> 00:20:10,443
So 'vh'
417
00:20:11,707 --> 00:20:13,083
And that's actually it.
418
00:20:14,080 --> 00:20:18,523
So basically this will be 100% of the available viewport.
419
00:20:19,590 --> 00:20:21,203
So if we give it a save,
420
00:20:22,100 --> 00:20:25,060
well, then that's exactly what happened.
421
00:20:25,060 --> 00:20:27,803
So it's now 100% of the viewport.
422
00:20:28,880 --> 00:20:31,700
So it ends exactly down here.
423
00:20:31,700 --> 00:20:32,770
And if we shrink this
424
00:20:34,605 --> 00:20:35,453
then,
425
00:20:36,610 --> 00:20:40,110
well, the height keeps being at 100%
426
00:20:40,110 --> 00:20:42,083
of the available viewport right now.
427
00:20:45,160 --> 00:20:45,993
All right.
428
00:20:45,993 --> 00:20:49,230
So this is a trick that we use all the time.
429
00:20:49,230 --> 00:20:52,680
So vh, which means viewport height.
430
00:20:52,680 --> 00:20:55,570
And of course it could be any other value here,
431
00:20:55,570 --> 00:20:57,130
let's say 50,
432
00:20:57,130 --> 00:21:00,937
and then it would be exactly half of the viewport.
433
00:21:00,937 --> 00:21:03,020
And of course it could be even more,
434
00:21:03,020 --> 00:21:05,120
like 150,
435
00:21:05,120 --> 00:21:06,280
then it would be essentially
436
00:21:06,280 --> 00:21:08,803
one-and-a-half of the viewport.
437
00:21:10,880 --> 00:21:11,713
Right.
438
00:21:11,713 --> 00:21:13,180
But usually we don't do that.
439
00:21:13,180 --> 00:21:16,930
We just leave it at a hundred, or some lower value.
440
00:21:16,930 --> 00:21:21,010
Now there's also another similar unit, which is 'vw',
441
00:21:21,010 --> 00:21:23,470
which stands for a viewport width.
442
00:21:23,470 --> 00:21:26,000
however, we don't need to use that here.
443
00:21:26,000 --> 00:21:29,830
And in fact, we very rarely use that one because,
444
00:21:29,830 --> 00:21:32,020
since these are all block elements,
445
00:21:32,020 --> 00:21:36,070
they will already occupy 100% of the available space
446
00:21:36,070 --> 00:21:37,510
by default.
447
00:21:37,510 --> 00:21:38,820
Right.
448
00:21:38,820 --> 00:21:41,220
So no need for that.
449
00:21:41,220 --> 00:21:44,460
All we need to specify is the height.
450
00:21:44,460 --> 00:21:45,770
Okay.
451
00:21:45,770 --> 00:21:50,180
So this was actually the first part of the video.
452
00:21:50,180 --> 00:21:52,980
So we managed to do these basic things,
453
00:21:52,980 --> 00:21:56,250
some basic styling and some very basic layout.
454
00:21:56,250 --> 00:21:58,210
And so let's take a small break here.
455
00:21:58,210 --> 00:21:59,680
And then when we come back,
456
00:21:59,680 --> 00:22:03,170
we will actually center this entire box here vertically,
457
00:22:03,170 --> 00:22:06,230
and we will add that beautiful background image.
458
00:22:06,230 --> 00:22:09,363
So I'll see you back here after a small break.
30575
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.