Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,380 --> 00:00:04,250
Welcome back to the next lecture
2
00:00:04,250 --> 00:00:07,200
where we will now finally start building
3
00:00:07,200 --> 00:00:08,760
our Omnifood project.
4
00:00:08,760 --> 00:00:11,690
And we're going to start with the hero section.
5
00:00:11,690 --> 00:00:16,070
And for that, I already created this sketch here.
6
00:00:16,070 --> 00:00:19,080
So as I mentioned before, we will create this layout
7
00:00:19,080 --> 00:00:21,490
where we have the hero image on the right side,
8
00:00:21,490 --> 00:00:24,360
and then the content such as the headline
9
00:00:24,360 --> 00:00:27,370
and some description on the left side.
10
00:00:27,370 --> 00:00:30,740
So exactly like these two examples that I have selected
11
00:00:30,740 --> 00:00:34,150
from our a layout gallery lecture.
12
00:00:34,150 --> 00:00:35,800
Now, on top of the section,
13
00:00:35,800 --> 00:00:39,340
there is kind of this logo and the navigation bar,
14
00:00:39,340 --> 00:00:42,360
but this is something that we will do a bit later.
15
00:00:42,360 --> 00:00:45,540
So it's actually not part of the hero itself,
16
00:00:45,540 --> 00:00:49,180
but it's kind of part of the start,
17
00:00:49,180 --> 00:00:51,220
of the beginning of the website.
18
00:00:51,220 --> 00:00:54,580
And so that's why I put it here as well.
19
00:00:54,580 --> 00:00:57,600
Now, also we will add to this small component
20
00:00:57,600 --> 00:01:00,410
that I have highlighted in red here in the bottom,
21
00:01:00,410 --> 00:01:02,610
which is these customer photos
22
00:01:02,610 --> 00:01:04,645
and then with some relevant data.
23
00:01:04,645 --> 00:01:06,940
So that was not in the sketch before,
24
00:01:06,940 --> 00:01:10,930
but now here I have it and you will see that it makes sense
25
00:01:10,930 --> 00:01:13,420
with the content that we have.
26
00:01:13,420 --> 00:01:14,320
Okay.
27
00:01:14,320 --> 00:01:18,290
And so now let's actually start building this hero section
28
00:01:18,290 --> 00:01:19,513
in VS Code.
29
00:01:21,320 --> 00:01:25,193
And let's start by removing what we did previously.
30
00:01:26,580 --> 00:01:27,940
Okay.
31
00:01:27,940 --> 00:01:31,660
And now I want to show you a very nice and important trick,
32
00:01:31,660 --> 00:01:35,450
which basically will allow us to have the HTML and the CSS
33
00:01:35,450 --> 00:01:38,693
files opened at the same time, side-by-side.
34
00:01:39,770 --> 00:01:43,700
So to do that, I will open again, the CSS file,
35
00:01:43,700 --> 00:01:46,460
and then I can click here on this icon.
36
00:01:46,460 --> 00:01:50,060
So this one that says split editor right.
37
00:01:50,060 --> 00:01:51,580
Now, if you cannot see it,
38
00:01:51,580 --> 00:01:54,750
you can also do the same thing here in "view"
39
00:01:54,750 --> 00:01:57,070
and then "editor layout".
40
00:01:57,070 --> 00:02:00,060
So you can then choose one of these options here,
41
00:02:00,060 --> 00:02:04,130
but usually I just click here and then that will open this
42
00:02:04,130 --> 00:02:06,783
exact same file here on the right side.
43
00:02:07,630 --> 00:02:08,510
Okay.
44
00:02:08,510 --> 00:02:11,610
Then I can close it here and then to give ourselves
45
00:02:11,610 --> 00:02:16,610
some more space, we closed down the sidebar and that's it.
46
00:02:18,590 --> 00:02:22,160
So here we usually need more space for the HTML
47
00:02:23,790 --> 00:02:26,980
and yeah, I think that's perfect.
48
00:02:26,980 --> 00:02:29,870
And so now we can basically work on both files
49
00:02:29,870 --> 00:02:31,600
at the same time.
50
00:02:31,600 --> 00:02:32,460
All right.
51
00:02:32,460 --> 00:02:35,890
But now about or actual hero section here,
52
00:02:35,890 --> 00:02:39,150
let's indeed use a section element,
53
00:02:39,150 --> 00:02:43,863
which basically represents a generic part of any document.
54
00:02:45,890 --> 00:02:49,680
So let's use section here and then give it to class
55
00:02:49,680 --> 00:02:53,490
of "section-hero".
56
00:02:53,490 --> 00:02:57,190
So I usually like to give all my sections then a class name,
57
00:02:57,190 --> 00:02:59,870
which also starts with section.
58
00:02:59,870 --> 00:03:03,450
So that then makes it easy to identify, right?
59
00:03:03,450 --> 00:03:05,610
So we talked about section,
60
00:03:05,610 --> 00:03:07,550
so the section element before,
61
00:03:07,550 --> 00:03:10,770
and it is a little bit similar to the article element,
62
00:03:10,770 --> 00:03:14,430
but the article is more self-contained basically.
63
00:03:14,430 --> 00:03:16,190
So for a section to exist,
64
00:03:16,190 --> 00:03:18,840
there should usually be multiple sections,
65
00:03:18,840 --> 00:03:22,363
which are then part of something bigger, right?
66
00:03:23,260 --> 00:03:25,330
So let's then...
67
00:03:25,330 --> 00:03:27,340
Well, let's move that in later.
68
00:03:27,340 --> 00:03:29,530
For now, let's actually keep going.
69
00:03:29,530 --> 00:03:32,210
And so now I want to create the two boxes
70
00:03:32,210 --> 00:03:35,040
which will then contain on the right side, the image
71
00:03:35,040 --> 00:03:37,533
and on the left side the text content.
72
00:03:38,420 --> 00:03:41,410
So let's create a div element for that,
73
00:03:41,410 --> 00:03:44,170
which remember is simply like a box
74
00:03:44,170 --> 00:03:46,423
which has no semantic meaning at all.
75
00:03:48,330 --> 00:03:52,473
So I'm gonna call this one the "hero-text-box"
76
00:03:53,890 --> 00:03:58,070
and that is the one that will contain among other elements
77
00:03:58,070 --> 00:04:03,070
this H1 hero, and then we also want the hero-image-box.
78
00:04:10,540 --> 00:04:13,660
So hero-image-box,
79
00:04:13,660 --> 00:04:17,113
and then we can immediately actually put the image in here.
80
00:04:19,910 --> 00:04:22,677
So that is in the folder, IMG/
81
00:04:24,310 --> 00:04:26,573
and then it is our hero image.
82
00:04:29,680 --> 00:04:33,393
Now, you see that it worked because it's already right here.
83
00:04:34,520 --> 00:04:35,410
Okay.
84
00:04:35,410 --> 00:04:38,593
But now let's keep going and add some more content here.
85
00:04:41,070 --> 00:04:44,663
So our content of course is here in the MD file.
86
00:04:46,180 --> 00:04:48,860
So this is the one that we already have,
87
00:04:48,860 --> 00:04:50,070
so the headline,
88
00:04:50,070 --> 00:04:52,763
and then here is this a summary basically.
89
00:04:54,490 --> 00:04:57,123
So let's just copy all this texts.
90
00:05:02,390 --> 00:05:04,913
I'm gonna call this one the "hero-description"
91
00:05:08,650 --> 00:05:09,863
and there we go.
92
00:05:11,170 --> 00:05:13,000
Here, let's also add a class
93
00:05:15,670 --> 00:05:17,233
for heading-primary.
94
00:05:20,700 --> 00:05:21,533
Okay.
95
00:05:21,533 --> 00:05:24,480
Because then later we will have some classes also
96
00:05:24,480 --> 00:05:27,770
for the secondary and tertiary headings.
97
00:05:27,770 --> 00:05:30,980
So the H2 and the H3 elements.
98
00:05:30,980 --> 00:05:33,790
And of course we could simply select the H1
99
00:05:33,790 --> 00:05:36,925
using this H1 element selector, right,
100
00:05:36,925 --> 00:05:41,070
but actually I like to always select all the elements
101
00:05:41,070 --> 00:05:46,070
using classes so no ID selectors and no elements selectors,
102
00:05:46,620 --> 00:05:50,000
everything will always be selected using classes
103
00:05:50,000 --> 00:05:53,973
because that will give our CSS code a lot more consistency.
104
00:05:56,034 --> 00:05:56,888
Okay.
105
00:05:56,888 --> 00:05:59,170
So we have the heading, then we have the description.
106
00:05:59,170 --> 00:06:03,720
And now we also want two buttons here below this.
107
00:06:03,720 --> 00:06:06,069
So just like in that layout pattern example
108
00:06:06,069 --> 00:06:09,310
that we saw at the beginning of this lecture.
109
00:06:09,310 --> 00:06:13,070
And for that, I'm actually going to use an anchor element,
110
00:06:13,070 --> 00:06:15,040
so a link basically,
111
00:06:15,040 --> 00:06:18,560
because links are foregoing somewhere on the page
112
00:06:18,560 --> 00:06:20,790
or going to some other page
113
00:06:20,790 --> 00:06:24,830
while a button element should only be used for actions.
114
00:06:24,830 --> 00:06:29,140
So if something happens that is not related to navigation,
115
00:06:29,140 --> 00:06:29,973
basically.
116
00:06:32,170 --> 00:06:35,703
So here for now, we will create an empty link.
117
00:06:36,720 --> 00:06:37,700
Okay.
118
00:06:37,700 --> 00:06:41,040
And then let's see if in the content we have some texts
119
00:06:41,040 --> 00:06:46,040
to put on the button, but actually there is nothing
120
00:06:46,630 --> 00:06:49,830
and so these types of small texts,
121
00:06:49,830 --> 00:06:54,110
so just a small piece of text, we usually call microcopy.
122
00:06:54,110 --> 00:06:57,830
And many times we have to come up with those as we design
123
00:06:57,830 --> 00:06:59,973
and build the websites ourselves.
124
00:07:00,810 --> 00:07:03,790
Now this button here is going to be the main call
125
00:07:03,790 --> 00:07:06,020
to action button of this page.
126
00:07:06,020 --> 00:07:08,943
And so let's not think what we could write there.
127
00:07:09,870 --> 00:07:13,410
So the main action that we want to use it to take here
128
00:07:13,410 --> 00:07:17,700
is to basically subscribe to the Omnifood subscription,
129
00:07:17,700 --> 00:07:18,533
right.
130
00:07:18,533 --> 00:07:21,800
And so here we should write something related to that.
131
00:07:21,800 --> 00:07:24,400
And since the focus of this company
132
00:07:24,400 --> 00:07:29,070
is all on like healthy eating and things like that,
133
00:07:29,070 --> 00:07:34,070
we can simply right here, "start eating well" for example.
134
00:07:35,400 --> 00:07:36,233
Okay.
135
00:07:38,090 --> 00:07:40,630
And it could be of course, anything similar,
136
00:07:40,630 --> 00:07:43,410
but it should be like a specific action.
137
00:07:43,410 --> 00:07:47,307
So it wouldn't be really helpful to just write here,
138
00:07:47,307 --> 00:07:51,680
"sign up now" or "buy now" or something like that.
139
00:07:51,680 --> 00:07:53,570
So that doesn't sound so nice
140
00:07:53,570 --> 00:07:57,920
and so instead we want a very specific action like this
141
00:07:57,920 --> 00:08:00,383
which makes the user feel better immediately.
142
00:08:01,290 --> 00:08:04,640
So "start eating well" I think it's a lot more compelling
143
00:08:04,640 --> 00:08:09,640
than like "sign up now" or "subscribe now" right.
144
00:08:10,150 --> 00:08:14,540
And here, just adding the button a class, you know,
145
00:08:14,540 --> 00:08:17,290
besides that we want another button,
146
00:08:17,290 --> 00:08:20,230
which is usually like a secondary button,
147
00:08:20,230 --> 00:08:22,630
which is going to be a secondary button.
148
00:08:22,630 --> 00:08:25,330
And this is usually used for something like
149
00:08:25,330 --> 00:08:27,183
getting additional information.
150
00:08:29,590 --> 00:08:34,313
So a popular text here is simply learn more.
151
00:08:35,400 --> 00:08:38,900
And then we can add some arrow here as well.
152
00:08:38,900 --> 00:08:43,080
So using an HTML entity and we already used R
153
00:08:43,080 --> 00:08:48,080
and then, I think, this here, which is the right arrow.
154
00:08:49,610 --> 00:08:52,000
Yeah, you can see it there in the tool tip,
155
00:08:52,000 --> 00:08:55,800
but then we also have DR which stands for down arrow,
156
00:08:55,800 --> 00:08:59,090
and again, it's visible now they're in the tool tip.
157
00:08:59,090 --> 00:09:02,490
And so this makes a bit more sense in this case.
158
00:09:02,490 --> 00:09:03,520
Okay.
159
00:09:03,520 --> 00:09:06,120
And with this, I think we are ready to check out
160
00:09:06,120 --> 00:09:07,423
what we have already.
161
00:09:09,690 --> 00:09:12,590
And as always, the image is really big
162
00:09:12,590 --> 00:09:16,170
and so remember that we need to make it flexible now.
163
00:09:16,170 --> 00:09:20,130
So that's one of the ingredients of responsive web design.
164
00:09:20,130 --> 00:09:23,608
Remember that then there is also the rest of the content
165
00:09:23,608 --> 00:09:27,780
and so let's now start styling this a little bit
166
00:09:27,780 --> 00:09:31,470
and actually starting with the layout.
167
00:09:31,470 --> 00:09:34,610
So putting these two boxes here, side by side,
168
00:09:34,610 --> 00:09:38,263
so one with the image and one with this text, okay.
169
00:09:40,326 --> 00:09:44,370
Now for doing this, I'm actually going to use CSS Grid,
170
00:09:44,370 --> 00:09:46,140
even though it's actually more like
171
00:09:46,140 --> 00:09:50,230
a one dimensional layout, so it's a really just a row,
172
00:09:50,230 --> 00:09:52,470
but I'm still going to use CSS Grid
173
00:09:52,470 --> 00:09:54,150
because it makes it really easy
174
00:09:54,150 --> 00:09:56,500
to have equally sized columns
175
00:09:56,500 --> 00:10:00,840
and also because I like to use the same tool for layout
176
00:10:00,840 --> 00:10:02,620
across the entire page.
177
00:10:02,620 --> 00:10:05,730
And later, of course, we are going to use CSS Grid
178
00:10:05,730 --> 00:10:08,197
for some other layout stuff and then,
179
00:10:08,197 --> 00:10:09,780
yeah, as I said,
180
00:10:09,780 --> 00:10:12,520
I like to just use the same thing everywhere.
181
00:10:12,520 --> 00:10:13,870
No, right.
182
00:10:13,870 --> 00:10:17,550
But even if we used flexbox instead of CSS Grid,
183
00:10:17,550 --> 00:10:20,087
we would still need some container element
184
00:10:20,087 --> 00:10:25,087
for these two boxes, so the image-box and the text-box.
185
00:10:26,360 --> 00:10:27,610
Right.
186
00:10:27,610 --> 00:10:31,850
So that grid container could of course be this section here
187
00:10:31,850 --> 00:10:33,470
or here, right.
188
00:10:33,470 --> 00:10:37,060
But then if we were to choose this one as the container,
189
00:10:37,060 --> 00:10:40,800
then we couldn't create a fixed sized container
190
00:10:40,800 --> 00:10:43,860
like we want to, okay.
191
00:10:43,860 --> 00:10:46,783
So let's actually create another element here.
192
00:10:49,570 --> 00:10:52,247
So one that I'm going to call a "hero".
193
00:10:53,440 --> 00:10:57,500
And if this doesn't make a lot of sense right now,
194
00:10:57,500 --> 00:11:00,800
it will make sense in a minute once you actually see
195
00:11:00,800 --> 00:11:03,813
what I'm talking about, okay.
196
00:11:05,890 --> 00:11:09,387
So again, this hero here will actually be
197
00:11:09,387 --> 00:11:11,323
our CSS Grid container.
198
00:11:12,830 --> 00:11:14,750
So let's select that.
199
00:11:14,750 --> 00:11:16,640
And now you can see how handy it is
200
00:11:16,640 --> 00:11:20,923
to have these two panels here, side by side, right.
201
00:11:23,030 --> 00:11:25,750
So display grid,
202
00:11:25,750 --> 00:11:30,270
and now, as I said, we will make two equally sized columns.
203
00:11:30,270 --> 00:11:33,630
So grid-template-columns, remember.
204
00:11:33,630 --> 00:11:37,340
And so here, we just need to give them the same value.
205
00:11:37,340 --> 00:11:42,340
And so usually that's 1fr and then another 1fr.
206
00:11:42,710 --> 00:11:46,170
So two fractional units right there.
207
00:11:46,170 --> 00:11:49,670
And so with this, they should now be side-by-side
208
00:11:49,670 --> 00:11:51,200
and indeed they are,
209
00:11:51,200 --> 00:11:54,680
but they do not have the same size, right.
210
00:11:54,680 --> 00:11:57,590
And the reason for that is this huge image
211
00:11:57,590 --> 00:12:00,043
which is still not really flexible.
212
00:12:01,060 --> 00:12:04,793
So before we do anything else, let's actually fix that.
213
00:12:05,980 --> 00:12:09,090
And so here, let's give it a class name.
214
00:12:09,090 --> 00:12:12,080
So it's the "hero-image".
215
00:12:12,080 --> 00:12:16,060
Oh, and actually we need to add the art-text as well.
216
00:12:16,060 --> 00:12:18,700
So never forget to do that.
217
00:12:18,700 --> 00:12:22,870
And so here, let's say that it's "a woman enjoying food"
218
00:12:25,270 --> 00:12:30,270
but that's not all, there's also "meals in storage container
219
00:12:33,537 --> 00:12:38,537
"and food bowls on a table."
220
00:12:41,610 --> 00:12:44,650
So it really descriptive all text here,
221
00:12:44,650 --> 00:12:48,330
but that's really nice for people who cannot see
222
00:12:48,330 --> 00:12:52,453
these images or also remember for search engines.
223
00:12:53,980 --> 00:12:54,813
Yeah.
224
00:12:54,813 --> 00:12:58,503
And now selecting the image with the class we just gave it,
225
00:13:00,410 --> 00:13:05,410
all we have to do now is to give it a width of exactly 100%,
226
00:13:05,810 --> 00:13:10,240
because 100% will then fill the entire parent element
227
00:13:10,240 --> 00:13:13,180
which is this hero-image box here,
228
00:13:13,180 --> 00:13:17,120
which is exactly one of the two columns of the grid.
229
00:13:17,120 --> 00:13:19,930
And so that column will have half the size
230
00:13:19,930 --> 00:13:22,680
of the grid container and so then the image
231
00:13:22,680 --> 00:13:25,210
of course, will also have half the width
232
00:13:25,210 --> 00:13:27,770
of the container now.
233
00:13:27,770 --> 00:13:30,560
Okay, and if we resize this year,
234
00:13:30,560 --> 00:13:34,800
then you see that indeed the image does resize as well.
235
00:13:34,800 --> 00:13:38,423
And so it is already at this point a flexible image.
236
00:13:39,960 --> 00:13:41,410
Okay.
237
00:13:41,410 --> 00:13:44,720
But now let's actually do what I mentioned to be the reason
238
00:13:44,720 --> 00:13:47,260
why we need this hero element here,
239
00:13:47,260 --> 00:13:51,623
which is to give it a fixed width, right.
240
00:13:52,550 --> 00:13:57,203
So remember that we used to use the width property for that,
241
00:13:58,085 --> 00:14:03,085
and I'm going to give it a 1300 pixels
242
00:14:03,400 --> 00:14:05,420
but remember from the last lecture
243
00:14:05,420 --> 00:14:09,870
that we will no longer use pixels now, right.
244
00:14:09,870 --> 00:14:13,030
And remember what instead we use,
245
00:14:13,030 --> 00:14:15,210
well, we use the rem unit,
246
00:14:15,210 --> 00:14:20,210
which before we set one rem here to being exactly 10 pixels.
247
00:14:21,090 --> 00:14:21,923
Right.
248
00:14:21,923 --> 00:14:26,630
And so here we do not want 1300 pixels, but we want 130 rem.
249
00:14:28,970 --> 00:14:30,150
Right.
250
00:14:30,150 --> 00:14:32,550
So that's one thing that we needed to fix here
251
00:14:32,550 --> 00:14:36,070
and the other one is actually this width property,
252
00:14:36,070 --> 00:14:39,140
because what happens like this
253
00:14:40,640 --> 00:14:43,340
and let's actually give it some background color here.
254
00:14:47,420 --> 00:14:49,103
So just some random color here.
255
00:14:50,150 --> 00:14:52,833
And so now let's decrease this a little bit.
256
00:14:53,690 --> 00:14:56,880
And while just, as I mentioned in the last lecture
257
00:14:56,880 --> 00:14:59,940
now, of course, this element does not adjust
258
00:14:59,940 --> 00:15:04,000
to the view port, so to its parent element.
259
00:15:04,000 --> 00:15:07,470
And so therefore we then created this vertical scroll bars,
260
00:15:07,470 --> 00:15:10,300
which is of course not what we envision
261
00:15:10,300 --> 00:15:11,983
for a real world website.
262
00:15:12,870 --> 00:15:17,870
And so indeed what we want is max width, right?
263
00:15:18,130 --> 00:15:21,980
And so now when the element is larger than the container,
264
00:15:21,980 --> 00:15:25,123
it was simply occupy 100% of it.
265
00:15:25,960 --> 00:15:30,927
And so you see that this starts to look quite nice, right?
266
00:15:32,050 --> 00:15:34,900
So quite real world, at least.
267
00:15:34,900 --> 00:15:38,890
And so then once it becomes larger than the specified width,
268
00:15:38,890 --> 00:15:40,453
then it simply stays here.
269
00:15:42,420 --> 00:15:46,137
Okay, let's get rid of this.
270
00:15:46,137 --> 00:15:49,030
And then of course, we also want to center it
271
00:15:49,030 --> 00:15:52,060
in the view port and for that we're actually going to use
272
00:15:52,060 --> 00:15:56,323
our old trick of margin 0 auto.
273
00:15:57,340 --> 00:15:58,193
Okay.
274
00:15:59,530 --> 00:16:03,750
And so this is starting to look like a usable layout
275
00:16:03,750 --> 00:16:05,930
that we can now improve upon.
276
00:16:05,930 --> 00:16:09,803
And so let's do that next and take a small break now.
20919
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.