Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,530 --> 00:00:03,430
Let's continue working on
2
00:00:03,430 --> 00:00:06,560
our very small shoe article project,
3
00:00:06,560 --> 00:00:09,093
in this coding challenge number two.
4
00:00:10,520 --> 00:00:13,190
So just like before, use the results
5
00:00:13,190 --> 00:00:15,000
of the previous challenge
6
00:00:15,000 --> 00:00:17,400
as the starting point for this one.
7
00:00:17,400 --> 00:00:20,640
And if for some reason you don't have that code,
8
00:00:20,640 --> 00:00:21,780
then as always,
9
00:00:21,780 --> 00:00:24,670
I have the starter and the final code links
10
00:00:24,670 --> 00:00:28,580
somewhere in this lecture, but it would be better of course,
11
00:00:28,580 --> 00:00:30,490
if you would use your own code,
12
00:00:30,490 --> 00:00:32,930
maybe if you have it on CodePen,
13
00:00:32,930 --> 00:00:36,410
or if you're doing this challenge on your own computer
14
00:00:36,410 --> 00:00:39,200
using VSCode, all right?
15
00:00:39,200 --> 00:00:41,640
So, we ended up with this result
16
00:00:41,640 --> 00:00:43,883
in the last coding challenge.
17
00:00:44,830 --> 00:00:46,780
So remember it was this,
18
00:00:46,780 --> 00:00:50,130
and what I want you to do now is to use your new knowledge
19
00:00:50,130 --> 00:00:54,690
about the box model to arrive at this result.
20
00:00:54,690 --> 00:00:57,730
So you see that this article here,
21
00:00:57,730 --> 00:01:01,300
so this element is a lot more narrow now,
22
00:01:01,300 --> 00:01:05,130
and it is also nicely centered in the page.
23
00:01:05,130 --> 00:01:08,020
So the width of this container here,
24
00:01:08,020 --> 00:01:12,870
so this article element is 825 pixels.
25
00:01:12,870 --> 00:01:15,930
Next, you can see that many margins and paddings
26
00:01:15,930 --> 00:01:19,380
have been removed and so that probably means
27
00:01:19,380 --> 00:01:22,160
that there has been some global reset here.
28
00:01:22,160 --> 00:01:26,300
So do that just like we did in one of the lectures,
29
00:01:26,300 --> 00:01:28,980
but then of course keep adding back some paddings
30
00:01:28,980 --> 00:01:30,310
and some margins.
31
00:01:30,310 --> 00:01:33,690
So whenever you see some space here in this example,
32
00:01:33,690 --> 00:01:36,830
for example, here, inside of this heading,
33
00:01:36,830 --> 00:01:39,870
then of course you need to add back some space
34
00:01:39,870 --> 00:01:43,340
and you can do that using margin or padding as you know,
35
00:01:43,340 --> 00:01:46,660
so just choose the write one for the right situation
36
00:01:46,660 --> 00:01:48,800
or according to what you learned.
37
00:01:48,800 --> 00:01:51,850
Finally, another thing is that
38
00:01:51,850 --> 00:01:54,790
this button here now is a really wide,
39
00:01:54,790 --> 00:01:56,660
so it spans all the way
40
00:01:56,660 --> 00:01:59,170
from the left side to the right side,
41
00:01:59,170 --> 00:02:02,560
and also it now has this border here at the top
42
00:02:02,560 --> 00:02:04,810
so to create this illusion of a button
43
00:02:04,810 --> 00:02:06,690
even when we're hovering it.
44
00:02:06,690 --> 00:02:10,060
So see if you can maybe arrive at this result,
45
00:02:10,060 --> 00:02:12,890
but if you can't then that's of course,
46
00:02:12,890 --> 00:02:15,380
as always not a big problem.
47
00:02:15,380 --> 00:02:18,280
So just take some time now and really try
48
00:02:18,280 --> 00:02:21,750
to code up this challenge and I see you back here
49
00:02:21,750 --> 00:02:22,873
when you are done.
50
00:02:25,720 --> 00:02:26,553
Okay.
51
00:02:27,480 --> 00:02:30,923
So let's waste no time and start right away.
52
00:02:31,760 --> 00:02:33,593
And I will actually start,
53
00:02:35,040 --> 00:02:37,170
give us some more space here.
54
00:02:37,170 --> 00:02:40,663
So I will start with that global reset I mentioned,
55
00:02:41,670 --> 00:02:46,670
so adding a margin of zero and a padding of zero
56
00:02:47,160 --> 00:02:50,093
to every single element on the page.
57
00:02:51,150 --> 00:02:52,710
All right.
58
00:02:52,710 --> 00:02:57,710
And now I will actually make this product here,
59
00:02:57,780 --> 00:03:01,715
so this element, I will give it to the width of
60
00:03:01,715 --> 00:03:06,180
825 pixels as I had mentioned before.
61
00:03:06,180 --> 00:03:07,690
All right.
62
00:03:07,690 --> 00:03:12,050
And so now it's time to center this in the browser.
63
00:03:12,050 --> 00:03:13,110
And in the last lecture,
64
00:03:13,110 --> 00:03:15,300
I actually showed you how to do that.
65
00:03:15,300 --> 00:03:18,200
So there, we created an element that we called
66
00:03:18,200 --> 00:03:22,550
the container, and then we centered that inside of the body.
67
00:03:22,550 --> 00:03:25,320
Now, in this case, the container is basically
68
00:03:25,320 --> 00:03:27,750
this product here, right?
69
00:03:27,750 --> 00:03:30,080
And so that is where we add the width
70
00:03:30,080 --> 00:03:31,870
and so that's where we also set now
71
00:03:31,870 --> 00:03:34,593
the left and right margins to auto.
72
00:03:36,730 --> 00:03:40,740
So I'm using the shorthand here and giving it
73
00:03:40,740 --> 00:03:43,300
at the top and the bottom, zero
74
00:03:43,300 --> 00:03:45,560
and then left and right, auto.
75
00:03:45,560 --> 00:03:48,010
And so, here we go.
76
00:03:48,010 --> 00:03:50,893
Now it is centered inside of the body.
77
00:03:52,530 --> 00:03:56,440
Beautiful, but we can actually make this a bit better
78
00:03:56,440 --> 00:03:59,567
because now it's kind of glued to the top here
79
00:03:59,567 --> 00:04:01,330
and the same down here.
80
00:04:01,330 --> 00:04:04,330
So instead of having top and bottom at zero,
81
00:04:04,330 --> 00:04:06,900
let's set them to 50 pixels.
82
00:04:06,900 --> 00:04:10,380
And so, that then creates some space basically
83
00:04:10,380 --> 00:04:12,650
around this element.
84
00:04:12,650 --> 00:04:17,210
So we added 50 here, down here, and 50 here at the top.
85
00:04:17,210 --> 00:04:18,370
Great.
86
00:04:18,370 --> 00:04:22,730
Next, let's add some space back here in the heading,
87
00:04:22,730 --> 00:04:24,643
so that is the product title.
88
00:04:25,730 --> 00:04:29,360
And so, now we want some space inside of the element
89
00:04:29,360 --> 00:04:32,630
so that we can create some empty space here,
90
00:04:32,630 --> 00:04:35,370
which still has some background color.
91
00:04:35,370 --> 00:04:36,203
Right?
92
00:04:36,203 --> 00:04:38,610
So that's why we use padding because we want
93
00:04:38,610 --> 00:04:41,290
that space to be inside of the element
94
00:04:41,290 --> 00:04:43,150
and not outside of it.
95
00:04:43,150 --> 00:04:44,863
So if it was a margin,
96
00:04:45,930 --> 00:04:47,890
then it would look like this
97
00:04:47,890 --> 00:04:50,480
and then the background color would of course
98
00:04:50,480 --> 00:04:52,223
not be anywhere here.
99
00:04:53,740 --> 00:04:56,910
So because it's outside, right, we wanted inside
100
00:04:56,910 --> 00:04:59,390
and so then that's padding.
101
00:04:59,390 --> 00:05:00,620
All right.
102
00:05:00,620 --> 00:05:03,203
So that's starting to look a lot better.
103
00:05:04,150 --> 00:05:05,910
Now maybe let's create some space here
104
00:05:05,910 --> 00:05:09,170
between this shipping and this text.
105
00:05:09,170 --> 00:05:13,320
And so for that, so for creating some vertical space,
106
00:05:13,320 --> 00:05:15,693
I am again using margin bottom.
107
00:05:16,860 --> 00:05:20,210
So here in shipping, let's add
108
00:05:20,210 --> 00:05:21,640
some
109
00:05:21,640 --> 00:05:22,473
margin
110
00:05:23,920 --> 00:05:24,753
bottom
111
00:05:25,650 --> 00:05:28,363
of, let's say, 20 pixels.
112
00:05:30,280 --> 00:05:31,850
Yeah, that looks a lot better
113
00:05:32,780 --> 00:05:36,087
and let's take a look at the final result
114
00:05:36,087 --> 00:05:38,400
that we want to achieve.
115
00:05:38,400 --> 00:05:41,493
And so you see we have some space here as well.
116
00:05:42,370 --> 00:05:45,720
We also have some space below this heading here,
117
00:05:45,720 --> 00:05:49,550
and then this unordered list also moved back
118
00:05:50,550 --> 00:05:52,460
here inside of the container,
119
00:05:52,460 --> 00:05:56,540
because notice that right now, these bullets are outside.
120
00:05:56,540 --> 00:05:57,410
Right?
121
00:05:57,410 --> 00:05:59,283
And so let's not fix all of that.
122
00:06:03,560 --> 00:06:07,310
So let's start with this one here
123
00:06:07,310 --> 00:06:10,320
and giving it 15 pixels and as always,
124
00:06:10,320 --> 00:06:12,880
if your numbers here were different
125
00:06:12,880 --> 00:06:15,250
then that doesn't matter at all.
126
00:06:15,250 --> 00:06:16,480
All right.
127
00:06:16,480 --> 00:06:20,530
And now some space here between this link and this title,
128
00:06:20,530 --> 00:06:24,560
so this heading and the logical thing to do
129
00:06:24,560 --> 00:06:28,570
would probably be to add some margin bottom to the link,
130
00:06:28,570 --> 00:06:30,130
because as I said,
131
00:06:30,130 --> 00:06:34,010
the best thing to do is to stick to one of the directions,
132
00:06:34,010 --> 00:06:38,220
so to one of the sides and then always add the margin there.
133
00:06:38,220 --> 00:06:39,750
So let's try that.
134
00:06:39,750 --> 00:06:42,493
So it's this more info link,
135
00:06:44,900 --> 00:06:48,333
but you will see that this will actually not work.
136
00:06:50,240 --> 00:06:53,270
So you see we added it and it doesn't work.
137
00:06:53,270 --> 00:06:55,180
And the reason why it doesn't work
138
00:06:55,180 --> 00:06:58,653
is something that I will explain in the next lecture.
139
00:07:00,010 --> 00:07:00,843
All right.
140
00:07:01,750 --> 00:07:04,830
So what matters now is that this doesn't work
141
00:07:04,830 --> 00:07:08,020
because you basically cannot use margins
142
00:07:08,020 --> 00:07:12,780
on small elements like anchors, so like this link.
143
00:07:12,780 --> 00:07:15,180
And so instead, what we will do now
144
00:07:15,180 --> 00:07:18,060
is to add a margin to the top
145
00:07:18,970 --> 00:07:20,390
of this element.
146
00:07:20,390 --> 00:07:24,003
And so this will then visually look exactly the same way.
147
00:07:24,900 --> 00:07:28,440
Right, so adding 30 to the bottom of this,
148
00:07:28,440 --> 00:07:31,350
it looks essentially the same as adding 30
149
00:07:31,350 --> 00:07:32,663
to the top of this one.
150
00:07:35,930 --> 00:07:37,710
Next, let's then fix
151
00:07:39,060 --> 00:07:41,800
these bullet points that are outside of our
152
00:07:41,800 --> 00:07:43,630
container element.
153
00:07:43,630 --> 00:07:47,493
So margin left, let's say 20 pixels.
154
00:07:48,760 --> 00:07:50,433
Yeah, so that looks nice.
155
00:07:52,670 --> 00:07:55,820
And now I want to add some space here also
156
00:07:55,820 --> 00:07:57,483
between these elements.
157
00:07:58,340 --> 00:08:01,630
So that is this details list right here,
158
00:08:01,630 --> 00:08:04,150
and so let's select each of these elements
159
00:08:04,150 --> 00:08:05,253
that are in there.
160
00:08:07,740 --> 00:08:12,370
So .details-list
161
00:08:12,370 --> 00:08:15,450
and then all the li child elements
162
00:08:16,890 --> 00:08:19,810
So this right here is a descendant selector,
163
00:08:19,810 --> 00:08:22,250
just like we have learned previously
164
00:08:22,250 --> 00:08:24,890
and as we have used many times before.
165
00:08:24,890 --> 00:08:26,460
I think we have never used it
166
00:08:26,460 --> 00:08:29,900
where one of them is a class selector like this
167
00:08:29,900 --> 00:08:31,710
and the other is an element,
168
00:08:31,710 --> 00:08:33,820
but of course that's no problem.
169
00:08:33,820 --> 00:08:36,763
We can just combine them in any way that we want.
170
00:08:39,780 --> 00:08:41,993
And so let's now add that space,
171
00:08:43,100 --> 00:08:45,310
let's say some 10 pixels.
172
00:08:45,310 --> 00:08:47,310
And now finally to finish,
173
00:08:47,310 --> 00:08:51,130
let's work a little bit here on this button.
174
00:08:51,130 --> 00:08:54,713
So this one, and I'm going to start with some padding here.
175
00:08:55,970 --> 00:08:59,323
So adding some space inside of the button.
176
00:09:01,230 --> 00:09:04,700
So that already looks a lot nicer, right?
177
00:09:04,700 --> 00:09:07,580
But now let's have it go from one side
178
00:09:07,580 --> 00:09:09,580
all the way to the other side.
179
00:09:09,580 --> 00:09:13,230
So that's something very similar as we did with the image
180
00:09:13,230 --> 00:09:15,003
in one of the previous lectures.
181
00:09:16,060 --> 00:09:20,513
So we can simply give it a width of 100%.
182
00:09:21,350 --> 00:09:25,530
And so now it basically occupies the entire parent element,
183
00:09:25,530 --> 00:09:30,530
which is of course this complete article element.
184
00:09:30,660 --> 00:09:35,340
And now all that we are missing is that border at the top.
185
00:09:35,340 --> 00:09:40,340
Right, so remember that here in our demo, when we hover it,
186
00:09:40,430 --> 00:09:44,500
then it still kind of looks like a button, right,
187
00:09:44,500 --> 00:09:47,420
and in order to create that effect,
188
00:09:47,420 --> 00:09:49,060
so that kind of illusion,
189
00:09:49,060 --> 00:09:51,973
we need this border here at the top of the button.
190
00:09:53,150 --> 00:09:54,800
So let's add that
191
00:09:56,020 --> 00:09:57,080
and
192
00:09:58,130 --> 00:10:00,680
so it is basically the same border
193
00:10:00,680 --> 00:10:02,673
as goes around this article.
194
00:10:03,840 --> 00:10:05,510
So let's see what we have there
195
00:10:07,570 --> 00:10:10,410
and we can actually go ahead and copy it.
196
00:10:10,410 --> 00:10:12,610
The only thing that we need to then change
197
00:10:12,610 --> 00:10:16,183
is that we only want this border at the top, in this case.
198
00:10:17,840 --> 00:10:21,143
Okay, and now there we go.
199
00:10:22,300 --> 00:10:26,520
So beautiful, that works just nice.
200
00:10:26,520 --> 00:10:30,780
And I think with this, we actually finished this challenge.
201
00:10:30,780 --> 00:10:34,500
So it looks just like, our demo here.
202
00:10:34,500 --> 00:10:37,560
So I think we're done here with this challenge.
203
00:10:37,560 --> 00:10:41,530
So great job, well done and congratulations
204
00:10:41,530 --> 00:10:45,410
for writing a lot of code on your own once again.
205
00:10:45,410 --> 00:10:48,370
So these are really, really important for you to
206
00:10:48,370 --> 00:10:50,320
consolidate your knowledge.
207
00:10:50,320 --> 00:10:51,970
So I'm very happy to see
208
00:10:51,970 --> 00:10:54,480
that you're still with me here at this point,
209
00:10:54,480 --> 00:10:56,883
because that's really great progress.
15010
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.