Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,400 --> 00:00:03,600
Let's now finally start making
2
00:00:03,600 --> 00:00:06,333
our Omnifoot website responsive.
3
00:00:07,870 --> 00:00:10,950
Now, before we actually write a single media query
4
00:00:10,950 --> 00:00:14,920
for our page, we first need to ensure that our HTML
5
00:00:14,920 --> 00:00:19,503
has one very important line, and that is this one here.
6
00:00:20,620 --> 00:00:24,830
So this Meditech here might seem quite unimportant,
7
00:00:24,830 --> 00:00:27,230
but actually for responsive web design,
8
00:00:27,230 --> 00:00:29,980
it is absolutely crucial.
9
00:00:29,980 --> 00:00:33,490
So if you wrote your HTML structure by hand,
10
00:00:33,490 --> 00:00:37,030
then you did not include of course this line of code here,
11
00:00:37,030 --> 00:00:41,030
and so you now need to pause the video and paste that down,
12
00:00:41,030 --> 00:00:45,160
because again, without this Meditech here,
13
00:00:45,160 --> 00:00:48,330
so without this line of code responsive web design
14
00:00:48,330 --> 00:00:52,490
will actually not work on physical mobile devices,
15
00:00:52,490 --> 00:00:55,710
so not on phones and not on tablets.
16
00:00:55,710 --> 00:00:59,630
And the reason for that is that browsers on mobile devices
17
00:00:59,630 --> 00:01:02,720
will basically zoom the page out by default
18
00:01:02,720 --> 00:01:04,810
until it fits the screen,
19
00:01:04,810 --> 00:01:07,830
and so that's not what we want with media queries.
20
00:01:07,830 --> 00:01:10,640
We simply want to make our entire layout
21
00:01:10,640 --> 00:01:14,960
so our entire design smaller, so less wide.
22
00:01:14,960 --> 00:01:17,630
And so therefore we need this line of code here,
23
00:01:17,630 --> 00:01:20,940
which will make it so that the page will actually match
24
00:01:20,940 --> 00:01:22,600
the screens with.
25
00:01:22,600 --> 00:01:24,683
So that's what this one here does.
26
00:01:25,600 --> 00:01:29,040
So the width will be equal to the device width,
27
00:01:29,040 --> 00:01:33,720
and the scale initially should be 100%, so one.
28
00:01:33,720 --> 00:01:36,360
And so what that means is that it will not
29
00:01:36,360 --> 00:01:39,603
zoom out of the page to fit it on the screen.
30
00:01:40,650 --> 00:01:44,700
Okay, but how this really works is not that important,
31
00:01:44,700 --> 00:01:47,823
but what matters is that you need to include this.
32
00:01:49,720 --> 00:01:53,673
So always include this line of code.
33
00:01:55,470 --> 00:01:58,320
Okay, so with that being said,
34
00:01:58,320 --> 00:02:00,580
let's now move on to media queries
35
00:02:00,580 --> 00:02:04,320
and let's delete this small experiment
36
00:02:04,320 --> 00:02:06,210
that we did previously,
37
00:02:06,210 --> 00:02:09,930
and so now what I'd like to do is to create a new file
38
00:02:09,930 --> 00:02:12,080
for the media queries.
39
00:02:12,080 --> 00:02:16,763
So here in our CSS folder, we create yet another file,
40
00:02:17,740 --> 00:02:20,763
and this one, I like to call queries.css.
41
00:02:22,170 --> 00:02:24,500
And then here in the HTML,
42
00:02:24,500 --> 00:02:27,820
of course, we need to include that file as well.
43
00:02:27,820 --> 00:02:31,900
So let's duplicate this last line and here change it
44
00:02:31,900 --> 00:02:35,310
to queries.css.
45
00:02:35,310 --> 00:02:38,250
And so now we have three CSS files,
46
00:02:38,250 --> 00:02:40,443
and well, that's no problem at all.
47
00:02:41,690 --> 00:02:45,010
So let's close this down and I will actually now move
48
00:02:45,010 --> 00:02:48,740
these other CSS files here to the left panel
49
00:02:48,740 --> 00:02:51,180
and then the queries on the right panel,
50
00:02:51,180 --> 00:02:52,640
and you will see in a minute
51
00:02:52,640 --> 00:02:55,670
why that is going to be really helpful.
52
00:02:55,670 --> 00:02:58,260
Okay, and so now we're ready to start writing
53
00:02:58,260 --> 00:02:59,700
our media queries,
54
00:02:59,700 --> 00:03:02,300
but for that, we need all breakpoints.
55
00:03:02,300 --> 00:03:05,350
So basically the width at which we want to set
56
00:03:05,350 --> 00:03:07,090
the media queries.
57
00:03:07,090 --> 00:03:10,350
So let's use those two methodologies that we studied
58
00:03:10,350 --> 00:03:12,060
in the last lecture.
59
00:03:12,060 --> 00:03:15,140
So basically looking where our design breaks,
60
00:03:15,140 --> 00:03:19,383
and also taking into account a common screen width ranges.
61
00:03:21,150 --> 00:03:23,740
So let's check it out here,
62
00:03:23,740 --> 00:03:26,310
and here we don't need all this space
63
00:03:26,310 --> 00:03:28,860
because all we are interested in here now
64
00:03:28,860 --> 00:03:32,390
is changing this width, and we can even make it
65
00:03:32,390 --> 00:03:35,663
a lot smaller here so that we can see our page a bit better.
66
00:03:37,520 --> 00:03:41,030
So let's start here at 1500 pixels,
67
00:03:41,030 --> 00:03:43,403
and starting to make our page smaller.
68
00:03:44,900 --> 00:03:49,900
Okay, now remember that here we have a container width
69
00:03:50,410 --> 00:03:53,233
of 1200 pixels down here,
70
00:03:54,410 --> 00:03:56,390
so that's our common container,
71
00:03:56,390 --> 00:04:01,160
but here we actually have a 1300, so it's a bit wider.
72
00:04:01,160 --> 00:04:02,900
And so already at this point here,
73
00:04:02,900 --> 00:04:05,790
we can see that the space here on this side
74
00:04:05,790 --> 00:04:08,450
between the Omnifoot and to the left side
75
00:04:08,450 --> 00:04:10,913
is getting bigger than the space here.
76
00:04:12,020 --> 00:04:14,940
And of course, that's going to become worse and worse
77
00:04:16,120 --> 00:04:17,503
as we decrease the width.
78
00:04:18,440 --> 00:04:21,680
So, here the design is not really breaking,
79
00:04:21,680 --> 00:04:24,740
but what we're gonna do is to at some point
80
00:04:24,740 --> 00:04:28,240
also make this hero here 1200 pixels wide,
81
00:04:28,240 --> 00:04:30,480
just as the rest of the page.
82
00:04:30,480 --> 00:04:34,073
So just as the common container element, all right?
83
00:04:35,460 --> 00:04:37,823
Now there is an extremely common screen size
84
00:04:37,823 --> 00:04:40,523
at 1,366 pixel.
85
00:04:41,410 --> 00:04:43,640
So somewhere around here,
86
00:04:43,640 --> 00:04:47,400
because these are these so-called HD ready screens,
87
00:04:47,400 --> 00:04:50,720
and so we can choose some value between 1300 maybe,
88
00:04:50,720 --> 00:04:53,670
and this one, all right?
89
00:04:53,670 --> 00:04:56,090
So let's set or first breakpoint there
90
00:04:56,090 --> 00:04:58,980
simply to make this hero just as wide
91
00:04:58,980 --> 00:05:01,120
as the rest of the page.
92
00:05:01,120 --> 00:05:04,203
So basically only that change, at least for now.
93
00:05:05,400 --> 00:05:08,160
Now there's one particularity about media queries
94
00:05:08,160 --> 00:05:09,650
that I didn't mention yet,
95
00:05:09,650 --> 00:05:13,310
which is the fact that we should also not use pixels
96
00:05:13,310 --> 00:05:14,940
in media queries.
97
00:05:14,940 --> 00:05:18,410
So just like we shouldn't use pixels for our layouts,
98
00:05:18,410 --> 00:05:21,380
we also shouldn't use them in media queries.
99
00:05:21,380 --> 00:05:24,050
And the reason for that is that using pixels
100
00:05:24,050 --> 00:05:26,980
will not adjust to the user's font size setting
101
00:05:26,980 --> 00:05:30,890
in the browser and also not to the user's zoom level.
102
00:05:30,890 --> 00:05:32,770
And so that is exactly the reason
103
00:05:32,770 --> 00:05:35,660
why throughout this whole project,
104
00:05:35,660 --> 00:05:38,860
we set the font size here to this percentage
105
00:05:38,860 --> 00:05:42,130
and not to a fixed size of 10 pixels
106
00:05:42,130 --> 00:05:44,330
like we had it previously here.
107
00:05:44,330 --> 00:05:45,770
Remember that?
108
00:05:45,770 --> 00:05:49,860
So that was the whole reason why here it is 62.5
109
00:05:49,860 --> 00:05:52,090
because it is 10 pixels,
110
00:05:52,090 --> 00:05:55,750
which is what we want, divided by the default browser
111
00:05:55,750 --> 00:05:57,280
font size setting.
112
00:05:57,280 --> 00:05:58,720
And so just like here,
113
00:05:58,720 --> 00:06:02,360
we should now use the REM instead of pixels.
114
00:06:02,360 --> 00:06:06,110
However, there is one very, very important particularity
115
00:06:06,110 --> 00:06:09,220
of these responsive units in media queries,
116
00:06:09,220 --> 00:06:12,130
which is the fact that they do not respond
117
00:06:12,130 --> 00:06:16,060
to this font size setting here in the HTML.
118
00:06:16,060 --> 00:06:19,130
Okay, so in other words what that means,
119
00:06:19,130 --> 00:06:23,880
is that in media queries, one REM is not 10 pixels,
120
00:06:23,880 --> 00:06:25,230
instead one REM
121
00:06:25,230 --> 00:06:28,763
will always be the default font size browser setting.
122
00:06:29,810 --> 00:06:34,770
So, let me write that here actually, REM and M,
123
00:06:35,650 --> 00:06:39,993
which is something similar as I will tell you in a minute,
124
00:06:42,040 --> 00:06:47,040
do not depend on HTML font size
125
00:06:48,840 --> 00:06:51,653
in media queries.
126
00:06:55,510 --> 00:07:00,510
Instead, we assume that one REM is equal to one M,
127
00:07:00,790 --> 00:07:03,493
is equal to 16 pixels.
128
00:07:04,360 --> 00:07:05,710
Now you might be wondering,
129
00:07:05,710 --> 00:07:10,480
what is this M unit here instead of REM?
130
00:07:10,480 --> 00:07:12,000
Well, this one here,
131
00:07:12,000 --> 00:07:14,330
so REM is the root font size,
132
00:07:14,330 --> 00:07:18,510
while M is basically the current font size,
133
00:07:18,510 --> 00:07:20,630
but that's not really important here
134
00:07:20,630 --> 00:07:23,400
because one REM is simply one M.
135
00:07:23,400 --> 00:07:25,930
But the reason why I'm even mentioning M here
136
00:07:25,930 --> 00:07:30,480
is because REM apparently has some bugs in some browsers
137
00:07:30,480 --> 00:07:32,280
when used in media queries,
138
00:07:32,280 --> 00:07:36,750
and therefore we should not use REM in media queries but M.
139
00:07:36,750 --> 00:07:39,360
Now I'm not even sure if that's still the case,
140
00:07:39,360 --> 00:07:42,290
but let's do it like that anyway.
141
00:07:42,290 --> 00:07:43,870
So it safer like that,
142
00:07:43,870 --> 00:07:46,473
and it works in the exact same way as the REM.
143
00:07:48,350 --> 00:07:53,350
So media and then max width,
144
00:07:54,340 --> 00:07:57,660
and here, remember now we need to set a value in M
145
00:07:57,660 --> 00:08:00,480
and we didn't really choose the value yet,
146
00:08:00,480 --> 00:08:02,170
not even in pixels.
147
00:08:02,170 --> 00:08:04,833
But remember from our previous discussion here,
148
00:08:04,833 --> 00:08:09,110
that we were looking for some value between this one here
149
00:08:09,110 --> 00:08:10,910
and maybe 1300,
150
00:08:10,910 --> 00:08:14,723
so let's try maybe 1,350, okay?
151
00:08:17,840 --> 00:08:22,840
So to convert that to M, we simply divide that by 16 pixels.
152
00:08:23,930 --> 00:08:26,460
So I'm using this built in calculator here,
153
00:08:26,460 --> 00:08:29,010
but you can use any other.
154
00:08:29,010 --> 00:08:33,743
So 1,350 divided by 16.
155
00:08:34,770 --> 00:08:36,940
So that's this strange value here,
156
00:08:36,940 --> 00:08:39,650
but I prefer to use like round values,
157
00:08:39,650 --> 00:08:40,883
and so let's go with 84.
158
00:08:44,143 --> 00:08:45,976
So 84M, and that's it.
159
00:08:49,210 --> 00:08:50,860
Now here, let's add some comment,
160
00:08:51,740 --> 00:08:53,783
I will just get this code from here.
161
00:09:00,380 --> 00:09:02,430
And so this is below
162
00:09:02,430 --> 00:09:05,050
and let's calculate the pixels now again,
163
00:09:05,050 --> 00:09:07,390
and so that's then of course, the other way around,
164
00:09:07,390 --> 00:09:10,700
so 84 times 16.
165
00:09:10,700 --> 00:09:14,020
So this media query will under normal circumstances,
166
00:09:14,020 --> 00:09:19,020
fire at 1,344 pixels, so 1344 pixels.
167
00:09:22,010 --> 00:09:26,923
And so that's basically for smaller desktops,
168
00:09:28,070 --> 00:09:30,093
so smaller computers basically.
169
00:09:30,980 --> 00:09:35,980
Okay, so finally we have our first media query here
170
00:09:36,150 --> 00:09:38,640
and we also have our first breakpoint,
171
00:09:38,640 --> 00:09:41,230
and so now let's finally also write
172
00:09:41,230 --> 00:09:44,590
our very first CSS rule in this media query.
173
00:09:44,590 --> 00:09:46,710
And so we're gonna do what I said before,
174
00:09:46,710 --> 00:09:51,170
which is to change the max width here to also 1200,
175
00:09:51,170 --> 00:09:54,023
just like we have it in the general container.
176
00:09:54,910 --> 00:09:57,273
So just like this one here, right?
177
00:09:59,380 --> 00:10:01,263
So let's write that here.
178
00:10:06,370 --> 00:10:10,690
So max width 120 REM,
179
00:10:10,690 --> 00:10:12,970
and of course this REM here has nothing to do
180
00:10:12,970 --> 00:10:16,280
with this M here, it still works exactly the same way
181
00:10:16,280 --> 00:10:20,803
as before we even started with responsive web design.
182
00:10:22,410 --> 00:10:24,533
Okay, so I'll give it a save,
183
00:10:25,980 --> 00:10:30,563
and let's wait and there it is.
184
00:10:31,570 --> 00:10:34,230
You saw that there we changed our width
185
00:10:34,230 --> 00:10:36,830
and now it is completely aligned here
186
00:10:36,830 --> 00:10:39,000
with the rest of the content,
187
00:10:39,000 --> 00:10:41,083
so it has now with the exact same width.
188
00:10:41,970 --> 00:10:44,220
Now with that, we created a new problem,
189
00:10:44,220 --> 00:10:46,470
which is that now this heading here
190
00:10:46,470 --> 00:10:49,360
is switched to four lines basically,
191
00:10:49,360 --> 00:10:51,200
and this doesn't look so good,
192
00:10:51,200 --> 00:10:56,020
and so let's also put down this value here a little bit,
193
00:10:56,020 --> 00:10:58,443
so decrease it basically one step.
194
00:10:59,670 --> 00:11:01,393
So that's easy as well.
195
00:11:04,030 --> 00:11:07,320
So that's called the heading primary
196
00:11:08,840 --> 00:11:13,320
and let's actually get our most important
197
00:11:13,320 --> 00:11:14,573
styling values here,
198
00:11:16,890 --> 00:11:19,390
and this time I'm putting them here in the bottom,
199
00:11:21,440 --> 00:11:24,303
because with that, we will be able to easier to see them.
200
00:11:26,880 --> 00:11:31,090
So let's see what the H1 is right now.
201
00:11:31,090 --> 00:11:35,770
So it's at 5.2, so 52 pixels here,
202
00:11:35,770 --> 00:11:39,770
and so let's try to step it down to the value below,
203
00:11:39,770 --> 00:11:41,933
so 4.4 REM.
204
00:11:43,400 --> 00:11:46,913
So font size 4.4 REM,
205
00:11:48,060 --> 00:11:51,120
and that does indeed fix it.
206
00:11:51,120 --> 00:11:54,890
So let's see again and beautiful.
207
00:11:54,890 --> 00:11:58,590
So now, if the user has like a smaller screen,
208
00:11:58,590 --> 00:12:02,480
let's say some laptop that has maybe this size,
209
00:12:02,480 --> 00:12:04,890
then everything looks nice.
210
00:12:04,890 --> 00:12:08,523
Well, at least here because if we scroll down a little bit,
211
00:12:09,480 --> 00:12:10,870
then you see that here
212
00:12:10,870 --> 00:12:13,433
we actually start having some problems as well,
213
00:12:14,630 --> 00:12:17,693
and even more so when we start making it even smaller.
214
00:12:19,510 --> 00:12:23,160
So that problem actually starts quite early.
215
00:12:23,160 --> 00:12:26,040
So somewhere around this point,
216
00:12:26,040 --> 00:12:29,050
but let's not add too many media queries.
217
00:12:29,050 --> 00:12:34,030
So it's not a good practice to add like 10 or 15 or even 20
218
00:12:34,030 --> 00:12:37,500
media queries to fix every single problem,
219
00:12:37,500 --> 00:12:39,320
so that's not so good
220
00:12:39,320 --> 00:12:41,420
and so instead, what we will do here
221
00:12:41,420 --> 00:12:43,910
is to simply use our media query
222
00:12:43,910 --> 00:12:46,530
so the breakpoint that we already have,
223
00:12:46,530 --> 00:12:48,620
which is somewhere around here,
224
00:12:48,620 --> 00:12:50,870
and what we will do at that point
225
00:12:50,870 --> 00:12:54,530
is to switch this layout here from the three columns
226
00:12:54,530 --> 00:12:56,410
to just two, and with that,
227
00:12:56,410 --> 00:12:58,943
we should very easily fix this problem.
228
00:13:00,690 --> 00:13:04,693
All right, so that's in our style,
229
00:13:05,640 --> 00:13:08,440
and so now you can see why it is so helpful
230
00:13:08,440 --> 00:13:10,610
to have this one here open on the left
231
00:13:10,610 --> 00:13:12,100
and this on the right,
232
00:13:12,100 --> 00:13:14,860
because then you can very easily see the style on one
233
00:13:14,860 --> 00:13:17,453
and create a similar one on the other side.
234
00:13:19,250 --> 00:13:23,440
So that's right here and here is the gallery with it,
235
00:13:23,440 --> 00:13:24,373
three columns.
236
00:13:25,620 --> 00:13:27,313
So I'm just copying all of this,
237
00:13:29,060 --> 00:13:32,903
makes it a bit easier and just delete what I do not need.
238
00:13:35,420 --> 00:13:38,720
Switch it to two and that's it.
239
00:13:38,720 --> 00:13:39,603
Let's go back,
240
00:13:42,600 --> 00:13:43,983
and there we go.
241
00:13:45,010 --> 00:13:48,600
So now it appears that there is way too much space here,
242
00:13:48,600 --> 00:13:51,220
but well, we cannot make it perfect
243
00:13:51,220 --> 00:13:55,530
for every single screen size, okay?
244
00:13:55,530 --> 00:13:57,050
So one of the more common ones
245
00:13:57,050 --> 00:14:00,200
might be a 1200 pixels exactly,
246
00:14:00,200 --> 00:14:04,230
and so there, it does look quite okay, I think.
247
00:14:04,230 --> 00:14:06,190
I mean, it's not perfect here,
248
00:14:06,190 --> 00:14:09,190
but we don't need to worry about that
249
00:14:09,190 --> 00:14:12,760
because we will probably also add a media query next,
250
00:14:12,760 --> 00:14:14,770
somewhere around this width,
251
00:14:14,770 --> 00:14:17,793
because here some more problems start to appear.
252
00:14:18,640 --> 00:14:21,950
So now I just wanted to fix these first issues
253
00:14:21,950 --> 00:14:23,930
that appear at the very beginning,
254
00:14:23,930 --> 00:14:27,690
because remember how I mentioned in the last lecture
255
00:14:27,690 --> 00:14:30,110
or in the one before it, that what we do
256
00:14:30,110 --> 00:14:33,740
basically when we built a responsive design like this
257
00:14:33,740 --> 00:14:35,290
is to start at the top,
258
00:14:35,290 --> 00:14:39,030
so at the biggest width and then make it smaller and smaller
259
00:14:39,030 --> 00:14:42,400
and keep adjusting whenever our design breaks,
260
00:14:42,400 --> 00:14:44,350
at least that's the way we do it
261
00:14:44,350 --> 00:14:46,300
when we're building desktop first,
262
00:14:46,300 --> 00:14:48,240
which is the case here.
263
00:14:48,240 --> 00:14:50,530
Now, if we were building mobile first,
264
00:14:50,530 --> 00:14:53,860
then everything would be the opposite way.
265
00:14:53,860 --> 00:14:57,040
So then the code outside of the media queries,
266
00:14:57,040 --> 00:15:00,170
so basically all the code that's here and here
267
00:15:00,170 --> 00:15:02,510
would be for the smaller screens,
268
00:15:02,510 --> 00:15:05,140
and then we would keep increasing the browser window
269
00:15:05,140 --> 00:15:09,720
and would add media queries here using min-width,
270
00:15:09,720 --> 00:15:10,553
all right?
271
00:15:10,553 --> 00:15:12,940
But I'm not gonna go deep into that now
272
00:15:12,940 --> 00:15:15,590
because, well, that's not the way
273
00:15:15,590 --> 00:15:17,400
we are doing it here right now.
274
00:15:17,400 --> 00:15:18,900
And so I think for now,
275
00:15:18,900 --> 00:15:22,150
there's no need to learn that very deeply.
276
00:15:22,150 --> 00:15:26,230
So actually that's it for this breakpoint here,
277
00:15:26,230 --> 00:15:28,350
and so let's wrap up the video here
278
00:15:28,350 --> 00:15:31,393
and create our next breakpoint in the next one.
20623
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.