Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1 1
So let's now continue building 2
2
our animated button. 3
3
So this is the final page and the final button. 4
4
And what we're missing here is this white part 5
5
that looks like it zooms out to infinity when we hover, 6
6
and it comes back when we hover out. 7
7
See. 8
8
So this nice effect. 9
9
It's not really necessary, of course, to add this. 10
10
But it was a great opportunity to show you the power 11
11
of CSS and of pseudo-elements. 12
12
So let me show you how we do it. 13
13
So as I said, we're gonna use pseudo-elements. 14
14
And pseudo-elements allow us 15
15
to style certain parts of elements. 16
16
For example, the after pseudo-element that we're 17
17
gonna use adds like a virtual element 18
18
right after the element that we're selecting. 19
19
And we can then style that element. 20
20
And so using this after pseudo-element 21
21
can be really powerful to do some cool effects. 22
22
And once you master it, 23
23
you're gonna want to use it all the time. 24
24
So, let me just add 25
25
the after pseudo-element. 26
26
So the trick here is to add an element 27
27
that looks exactly like the button that we already have, 28
28
but we put it behind the button. 29
29
And when we hover out of the button, 30
30
then this hidden pseudo-element 31
31
amazingly goes back behind the button. 32
32
So let's see how we can do this. 33
33
First, in order for an after pseudo-element 34
34
to actually appear on the page, 35
35
we need to specify its content property. 36
36
So that's always necessary. 37
37
It doesn't matter what the content is. 38
38
It can even be empty like we're gonna do here, 39
39
but we have to specify it. 40
40
Otherwise it's not going to appear. 41
41
And the same thing with the display property. 42
42
So we have to specify the display property. 43
43
And in this case, we're gonna say it's an inline block 44
44
because the button that we have is also an inline block. 45
45
And so, again, we want it to be exactly the same. 46
46
We want it to look the same. 47
47
So we want to have a height of 100%. 48
48
And we want to have a width of 100% as well. 49
49
And this works because the after pseudo-element 50
50
is basically treated like a child of the button. 51
51
And so if we say that we want the height to be 100%, 52
52
that's 100% of the width of the button. 53
53
And so suppose that the button has 100 pixels 54
54
of height and 50 pixels of width. 55
55
And so this after pseudo-element 56
56
will have the exact same dimensions if we set it to 100%. 57
57
Now the border rate is, should also be the same. 58
58
100 pixels. 59
59
So something really big. 60
60
And now, we also want it to be white. 61
61
But in order for it to be white, 62
62
we actually should make another after pseudo-element 63
63
but this time for the button, right. 64
64
So let's put it here. 65
65
And after. 66
66
And so background color 67
67
should be white. 68
68
Alright. 69
69
Now let's just see on our page if it actually shows up. 70
70
So right now it still looks like it's part of our element. 71
71
And so we should change that. 72
72
So what we wanna do, 73
73
remember, 74
74
is to put it behind our actual button. 75
75
So how can we do that? 76
76
And we use absolute positioning. 77
77
So position and absolute. 78
78
And then we just say it should be zero from the top 79
79
and zero from the left. 80
80
Now remember that this absolute positioning 81
81
needs to have a reference. 82
82
And the reference is the first element 83
83
with the relative position that it can find. 84
84
Now in this case it would be the header 85
85
because remember we did that before. 86
86
But we don't want it to be the header. 87
87
We want it to be hidden after the button. 88
88
And so, the reference should be the button. 89
89
Therefore, what we have to do 90
90
is to set the position property of the button to relative. 91
91
Alright. 92
92
And so now it should be hidden behind the button. 93
93
Now one more thing that we have to do 94
94
is to set the z index. 95
95
And we will put it to minus one. 96
96
So remember the z index defines the position 97
97
of the elements if they are one on top of another. 98
98
And so this one has minus one 99
99
and so it's definitely behind the button. 100
100
Now since it's hidden, 101
101
I cannot really show it to you on the page now. 102
102
But we're gonna see it in a little bit. 103
103
So when do we actually want to see it. 104
104
We want to see it when we hover the button. 105
105
So what we're gonna do is to write it like this. 106
106
And this may seem a bit complicated, 107
107
but it's actually not. 108
108
So, when we hover the button, 109
109
then we want some certain styles 110
110
for the after pseudo-element. 111
111
So this looks a bit weird but it makes total sense. 112
112
So this is an after pseudo-element 113
113
only when we have the button on the hover state. 114
114
And what do we want to happen? 115
115
We want it to be bigger. 116
116
Right. Remember. 117
117
We want the element to grow and to fade out. 118
118
And so, what we first do is to use once again, 119
119
the transform property. 120
120
And I told you it was really important and, 121
121
so yeah, it is. 122
122
This time we do a scale. 123
123
So what scale does is to simply 124
124
increase the element. 125
125
So if we do scale two, 126
126
then it will appear double the size that it had before. 127
127
So now we can actually check if it's working alright. 128
128
So reload. 129
129
And, whoa. 130
130
There it is. 131
131
So this white part that you see 132
132
outside here is the pseudo-element 133
133
that becomes visible as soon as we hover over the button. 134
134
Let's actually make it a different color here, 135
135
like red, 136
136
just so that you can see the difference. 137
137
And whoa. 138
138
Now it's everything red. 139
139
But that's not a problem. 140
140
For some reason the original button is also getting red. 141
141
But we still can be sure the pseudo-element is behind 142
142
the button because we still can see the text. 143
143
And so that means that the original button 144
144
is still on top of the pseudo-element. 145
145
Let's put it back to white, where it was. 146
146
And we don't want to scale it this much. 147
147
So let's just say one point five. 148
148
And we also want this to be animated just like before. 149
149
So where do we have to put the transition property? 150
150
Exactly. 151
151
We do it on the initial state. 152
152
In this case the initial state is of course 153
153
this after pseudo-element. 154
154
So we say 155
155
transition, 156
156
and again I'm going to use all here, 157
157
and then use, let's say, point four seconds in this case. 158
158
So here we had point two, 159
159
but we want this one to take a little bit longer. 160
160
Now what also happens, 161
161
is that the element actually fades out. 162
162
So opacity zero. 163
163
That's the trick for fading something out, 164
164
is going to opacity zero. 165
165
We did that before in our other animation 166
166
in the lecture before, 167
167
and so here we're doing it again. 168
168
So opacity zero sets something to invisible basically. 169
169
So let's check out 170
170
if it works already. 171
171
Yeah, that's actually it. 172
172
It's already working, right? 173
173
It comes back. 174
174
It goes out and it comes back. 175
175
So, really cool, right? 176
176
Now we can make this a a little bit better 177
177
because if you look closely at the top of the button, 178
178
and you see that it looks really small. 179
179
So the part that's fading out is like really small. 180
180
Take a look. 181
181
So let's do this a bit better. 182
182
And actually with this I can show you 183
183
that there are different scales. 184
184
So scale, without any epsilon here, 185
185
simply scales the entire element. 186
186
But we can do scale x, 187
187
and then that's how it's gonna scale on the x direction. 188
188
On the x axis. 189
189
And here we want to do one point four. 190
190
And now scale, epsilon as you can imagine, 191
191
in the other direction. 192
192
So let's put one point six here. 193
193
So they are different scales. 194
194
Just like they are different translates, 195
195
or rotates, or other functions that we can put 196
196
here in the transform. 197
197
So, let's check it out. 198
198
And, yeah. 199
199
So now it looks a bit better. 200
200
So, really cool. 201
201
There's just one thing left here because, 202
202
take a look here what happens when we load the page. 203
203
You saw this. 204
204
This came up moving from the bottom. 205
205
So first, we saw these two elements coming in, 206
206
like we coded before. 207
207
And then the button came up 208
208
from the bottom to this position. 209
209
So let's very quickly code up 210
210
another animation for that. 211
211
And we're gonna put it here after this one. 212
212
Actually I'm gonna copy it 213
213
'cause it's pretty similar. 214
214
So move in, 215
215
let's say bottom now, 216
216
from the bottom. 217
217
This time we don't need any 80% 218
218
because it's just from one point to the other. 219
219
And now I'm going to leave it to you to specify, 220
220
let's see, 221
221
what we should put here. 222
222
So pause the video, 223
223
and try to figure out how this should look like. 224
224
So, did you figure it out? 225
225
How should the button be positioned 226
226
right in the beginning before the animation starts? 227
227
It should be a bit lower than its current position, right? 228
228
Because it's moving in from the bottom 229
229
to its original position. 230
230
And so we can do translate epsilon this time. 231
231
And put something like 30 pixels in here. 232
232
That's because remember, 233
233
for the epsilon direction 234
234
it goes like this. 235
235
So from top to bottom. 236
236
So if we want to move it down, it's a positive value. 237
237
Alright. 238
238
And let's now actually use this animation. 239
239
Now again there will be multiple buttons like this. 240
240
But I only want this animation to happen 241
241
on this particular button. 242
242
And so what I'm gonna do 243
243
is to create a new class on the button. 244
244
So button, 245
245
animated. 246
246
And only this button will have this class. 247
247
Okay? 248
248
So let's put it here. 249
249
Button. 250
250
Animated. 251
251
And then in here I will put the animation. 252
252
So animation, 253
253
and I'm going to use the shorten property 254
254
that I showed you before. 255
255
And now it's called move in bottom. 256
256
And let's use point five, second animation. 257
257
And we're gonna use an ease out this time. 258
258
Okay? 259
259
Now plus what we're gonna do is to have a delay. 260
260
So we don't want to start it at the same time as the others. 261
261
We want it to start slightly later. 262
262
So maybe not one entire second, 263
263
which is the animation time of the other two animations, 264
264
but maybe just 75% of that. 265
265
So .75 seconds. 266
266
So I told you that we could put all of 267
267
these values in the same animation property. 268
268
So this is the animation name, the animation duration, 269
269
the animation timing function, 270
270
and the animation delay. 271
271
So let's take a look at what happens here. 272
272
Alright, so you saw that. 273
273
Actually the button was visible 274
274
before the animation happened. 275
275
Let's take a look again. 276
276
So it stays visible and then it starts. 277
277
Now what could we do in order to prevent this. 278
278
We could simply put these initial states on the button. 279
279
But that would be highly impractical, right? 280
280
Wouldn't make much sense. 281
281
So there is another property related to animations. 282
282
And this one is called animation fill mode 283
283
So animation fill mode. 284
284
And now we can set it to backwards. 285
285
And what this does, 286
286
is that it will automatically apply 287
287
the styles up to zero percent before the animation starts. 288
288
So, again, these styles will now be applied 289
289
before the animation starts simply by using the 290
290
animation fill mode and set it to backwards. 291
291
So, pretty amazing right? 292
292
So it's really simple, simple solution to this problem. 293
293
And so let's try it again. 294
294
And, yeah, so here it works. 295
295
Alright. 296
296
And that's it for this lecture, 297
297
and actually for this section. 298
298
So, we've come a long way so far, 299
299
and we already coded a bunch of really cool stuff I think. 300
300
We already have the header already completed. 301
301
Only what's missing here is this navigation 302
302
but it's a bit too complex for now, 303
303
so we're gonna leave it for another time. 304
304
But for now, we've come far enough with this project 305
305
that it's now time to show you a little bit of 306
306
how CSS actually works behind the scenes. 307
307
So I have a couple of really great lectures 308
308
coming up which I spent a lot of time building for you. 309
309
But they will be really insightful and helpful, 310
310
I hope. 311
311
So, 312
312
review what we just did in this section maybe. 313
313
Or you can just move on to the next one right now. 314
314
Anyway, see you next time.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.