Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,440 --> 00:00:04,390
So now let me just very quickly show you
2
00:00:04,390 --> 00:00:08,310
how we can add dimensions to elements in CSS
3
00:00:08,310 --> 00:00:10,833
using the height and the width property.
4
00:00:12,400 --> 00:00:17,240
And let's once again, start with our side element down here
5
00:00:17,240 --> 00:00:20,780
which at some point later will be our sidebar.
6
00:00:20,780 --> 00:00:23,520
And so it shouldn't be as wide
7
00:00:23,520 --> 00:00:27,513
and instead we only wanted to be 500 pixels wide.
8
00:00:28,500 --> 00:00:31,690
So we can simply come here to our element
9
00:00:31,690 --> 00:00:36,690
and specify the width as 500 pixels.
10
00:00:38,070 --> 00:00:39,583
And just like that,
11
00:00:40,890 --> 00:00:45,840
now our side element is only 500 pixels wide.
12
00:00:45,840 --> 00:00:50,120
So a lot more narrow than the rest of the page.
13
00:00:50,120 --> 00:00:51,330
Okay.
14
00:00:51,330 --> 00:00:54,520
So very easy, very straightforward.
15
00:00:54,520 --> 00:00:57,060
That is the width property.
16
00:00:57,060 --> 00:00:58,993
Let's try another one.
17
00:00:59,950 --> 00:01:03,310
So actually let's try height now.
18
00:01:03,310 --> 00:01:07,750
And I'm doing that here in the main header.
19
00:01:07,750 --> 00:01:10,660
So here, let's set the height
20
00:01:10,660 --> 00:01:13,253
to let's say 80 pixels.
21
00:01:15,490 --> 00:01:16,670
All right.
22
00:01:16,670 --> 00:01:20,853
And now you saw how it increased here, right?
23
00:01:22,030 --> 00:01:24,963
Now let's actually inspect this header here.
24
00:01:27,500 --> 00:01:32,500
So not the link, but the entire header element, right?
25
00:01:32,500 --> 00:01:35,543
And if we check out the box model down here,
26
00:01:36,820 --> 00:01:39,030
so this is all a bit small
27
00:01:40,870 --> 00:01:42,590
but nevermind.
28
00:01:42,590 --> 00:01:46,230
So you can see that here we actually have the 80 pixels
29
00:01:46,230 --> 00:01:48,770
that we just specified, right?
30
00:01:48,770 --> 00:01:50,130
And then top of that,
31
00:01:50,130 --> 00:01:54,400
we have the 20 pixels to the top and to the bottom.
32
00:01:54,400 --> 00:01:57,770
And so the complete final size of the element
33
00:01:57,770 --> 00:02:01,750
is actually not the 80 pixels that we specified here,
34
00:02:01,750 --> 00:02:06,750
but it is 80 plus 20 plus 20, which is 120 pixels.
35
00:02:07,730 --> 00:02:11,740
So that is exactly that default behavior of the box model
36
00:02:11,740 --> 00:02:13,340
that I mentioned before
37
00:02:13,340 --> 00:02:17,650
and that in my opinion, doesn't make any sense at all.
38
00:02:17,650 --> 00:02:20,550
But again, we will fix that a little bit later.
39
00:02:20,550 --> 00:02:21,750
For now it is important
40
00:02:21,750 --> 00:02:25,800
to learn how the box model actually works originally.
41
00:02:25,800 --> 00:02:28,870
And so again the real height of this element
42
00:02:28,870 --> 00:02:31,910
is not the 80 that we specified here,
43
00:02:31,910 --> 00:02:34,330
but we would then have to add the padding
44
00:02:34,330 --> 00:02:35,593
to the top and bottom.
45
00:02:36,480 --> 00:02:37,710
Okay.
46
00:02:37,710 --> 00:02:41,610
Now, one thing that you also might have noticed here is
47
00:02:41,610 --> 00:02:44,680
that the content, so the text here,
48
00:02:44,680 --> 00:02:48,560
doesn't just magically get vertically centered inside
49
00:02:48,560 --> 00:02:50,360
of this header element.
50
00:02:50,360 --> 00:02:53,960
So it actually was vertically centered before,
51
00:02:53,960 --> 00:02:57,550
but that was simply because we had applied the same padding
52
00:02:57,550 --> 00:02:59,750
to both of the sides.
53
00:02:59,750 --> 00:03:02,070
But now not anymore.
54
00:03:02,070 --> 00:03:05,890
I mean, we still do have the same padding on both sides,
55
00:03:05,890 --> 00:03:08,420
but now we have this other height here.
56
00:03:08,420 --> 00:03:10,200
And so now the space that's at the bottom
57
00:03:10,200 --> 00:03:13,500
is no longer the space that's at the top.
58
00:03:13,500 --> 00:03:16,550
And actually, it's not really straightforward
59
00:03:16,550 --> 00:03:18,680
to center this vertically,
60
00:03:18,680 --> 00:03:21,593
but of course we will learn how a little bit later.
61
00:03:22,630 --> 00:03:23,890
Okay.
62
00:03:23,890 --> 00:03:25,160
So let's close it.
63
00:03:25,160 --> 00:03:29,310
And now let's actually finally talk about this image.
64
00:03:29,310 --> 00:03:33,600
So up until this point, it has been sitting here untouched,
65
00:03:33,600 --> 00:03:38,600
but now let's select it and let's actually size it.
66
00:03:38,660 --> 00:03:39,880
And for that,
67
00:03:39,880 --> 00:03:42,853
let's give it a class so that we can then select it.
68
00:03:44,340 --> 00:03:46,190
So...
69
00:03:46,190 --> 00:03:47,743
It is this one here.
70
00:03:48,670 --> 00:03:53,670
So class of 'posts-image' let's say.
71
00:03:55,830 --> 00:03:59,040
Copy it and then...
72
00:03:59,040 --> 00:04:00,880
Well, let's say...
73
00:04:04,100 --> 00:04:06,783
somewhere here at the very bottom actually.
74
00:04:10,170 --> 00:04:14,520
So this here was just a demo, so I'm putting it here.
75
00:04:14,520 --> 00:04:17,203
And now let's specify the width here.
76
00:04:18,630 --> 00:04:20,650
So it is actually very common
77
00:04:20,650 --> 00:04:25,650
to size images in CSS and not in HTML like we did.
78
00:04:25,890 --> 00:04:29,240
Actually many times, we never even specify the width
79
00:04:29,240 --> 00:04:33,220
of images in HTML but only in CSS.
80
00:04:33,220 --> 00:04:35,030
Now here for the first time,
81
00:04:35,030 --> 00:04:38,080
I will not use length in pixels.
82
00:04:38,080 --> 00:04:39,340
I mean, I could.
83
00:04:39,340 --> 00:04:44,340
For now, let's say 800 pixels.
84
00:04:45,190 --> 00:04:46,400
And so...
85
00:04:46,400 --> 00:04:51,163
Well, that looks like it actually was the wrong image
86
00:04:51,163 --> 00:04:52,403
that we selected here.
87
00:04:53,870 --> 00:04:57,233
So the class should be of course on this one.
88
00:04:58,650 --> 00:05:00,910
And so now that looks correct.
89
00:05:00,910 --> 00:05:03,760
And so that's 800 that we specified there
90
00:05:03,760 --> 00:05:07,170
did now override this 500.
91
00:05:07,170 --> 00:05:10,790
However, this 200 here is still in place.
92
00:05:10,790 --> 00:05:13,450
And that's why the aspect ratio is now
93
00:05:13,450 --> 00:05:16,110
like completely broken, right?
94
00:05:16,110 --> 00:05:18,070
So this doesn't look correct anymore.
95
00:05:18,070 --> 00:05:22,010
It's way stretched to the width.
96
00:05:22,010 --> 00:05:24,200
And so in order to fix that,
97
00:05:24,200 --> 00:05:27,970
in case we do have to height specified in HTML,
98
00:05:27,970 --> 00:05:32,970
what we need to do is to then set the height to 'auto'.
99
00:05:34,091 --> 00:05:35,960
And so that will then fix it
100
00:05:35,960 --> 00:05:39,373
and we'll put the aspect ratio back to the original.
101
00:05:40,210 --> 00:05:41,043
Okay.
102
00:05:41,043 --> 00:05:44,060
But again, specifying the height
103
00:05:44,060 --> 00:05:47,480
and setting it to auto is only necessary
104
00:05:47,480 --> 00:05:52,060
if that height is already specified before in HTML.
105
00:05:52,060 --> 00:05:54,110
In case we don't do that,
106
00:05:54,110 --> 00:05:58,350
so in case we don't specify any image dimensions in HTML,
107
00:05:58,350 --> 00:06:02,600
then if we set the height or the width using CSS,
108
00:06:02,600 --> 00:06:05,580
the other one will automatically adapt in order
109
00:06:05,580 --> 00:06:10,200
to account for the original aspect ratio of the image.
110
00:06:10,200 --> 00:06:13,580
So for example if we set this to 300,
111
00:06:13,580 --> 00:06:16,253
then it would become really small, right?
112
00:06:17,180 --> 00:06:18,550
But now, as I said,
113
00:06:18,550 --> 00:06:22,180
let's actually move away from pixels for the first time
114
00:06:22,180 --> 00:06:24,300
and use percentages.
115
00:06:24,300 --> 00:06:28,510
So I can say the width like this,
116
00:06:28,510 --> 00:06:30,480
so '100%'.
117
00:06:30,480 --> 00:06:34,090
And usually for a width measurement like this,
118
00:06:34,090 --> 00:06:37,170
the percentage is usually the percentage
119
00:06:37,170 --> 00:06:39,623
of the width of the parent container.
120
00:06:40,700 --> 00:06:44,620
So the parent of the post image is the header
121
00:06:44,620 --> 00:06:49,230
and this header is basically the entire width of the page.
122
00:06:49,230 --> 00:06:50,063
Right?
123
00:06:50,063 --> 00:06:52,970
And so if I say with of 100%,
124
00:06:52,970 --> 00:06:57,070
then this image should now be the width of the entire page.
125
00:06:57,070 --> 00:07:01,010
And indeed that is exactly what we get.
126
00:07:01,010 --> 00:07:03,680
And so what's special about this is that now
127
00:07:03,680 --> 00:07:06,880
as we change the size of the window,
128
00:07:06,880 --> 00:07:11,783
then the size of the image will always stay at 100%.
129
00:07:12,800 --> 00:07:13,633
Okay.
130
00:07:13,633 --> 00:07:17,053
Because that is always the size of the parent container.
131
00:07:18,210 --> 00:07:20,900
Of course we could set it to something else,
132
00:07:20,900 --> 00:07:24,023
like half of the size of the parent container.
133
00:07:25,170 --> 00:07:27,040
And what would still happen is that
134
00:07:27,040 --> 00:07:31,030
as we changed the size of the parent container,
135
00:07:31,030 --> 00:07:34,640
then the size of the image would also adapt.
136
00:07:34,640 --> 00:07:35,630
Okay.
137
00:07:35,630 --> 00:07:38,900
And this is something that will become very, very important
138
00:07:38,900 --> 00:07:42,970
once we start talking about building responsive websites,
139
00:07:42,970 --> 00:07:46,423
so websites that adapt to the screen width.
140
00:07:47,380 --> 00:07:48,350
Okay.
141
00:07:48,350 --> 00:07:51,000
But let's put it back to 100%,
142
00:07:51,000 --> 00:07:53,850
which is what we originally wanted.
143
00:07:53,850 --> 00:07:56,740
And with that, I think we are actually done
144
00:07:56,740 --> 00:08:00,683
with setting some heights and some width, at least for now.
10394
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.