All language subtitles for 4. Building the Header - Part 2

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1 1

In this lecture, we are gonna continue 2

2

building the header section of our project 3

3

using some CSS properties that you're already familiar with. 4

4

And you're also gonna learn the easiest 5

5

way to center anything in CSS with transform, top, and left. 6

6

Which is something really important. 7

7

So, this is where we left after the last lecture. 8

8

So let's now take a look at the final product. 9

9

And so what we're gonna do in this lecture, 10

10

is to just add this small logo here. 11

11

And then, we're also going to add this heading here. 12

12

So this is the plan for this lecture 13

13

And let's start with the image. 14

14

So first off, in the HTML, 15

15

we actually have to add that image. 16

16

So let's remove the text here. 17

17

And what I'm gonna do now is to add first a DIV, 18

18

and then inside that DIV is where I'm gonna put an image. 19

19

Because the image is actually an inline element, 20

20

and so I think it's a better practice 21

21

to first have a small container 22

22

where this image is inside, 23

23

and then position that container 24

24

to where we want the image and the container to be. 25

25

So first, I'm writing a DIV with a class of logo box. 26

26

And then in here, I'm going to put the image. 27

27

So we go into the image folder, so IMG, 28

28

and then from here, 29

29

the logo that we want is called logo white. 30

30

So it's this one here. 31

31

So, IMG, and then logo white. 32

32

And then we also give it an alt attribute. 33

33

And remember that the alt attribute is 34

34

to describe the image for SEO, 35

35

so Search Engine Optimization, 36

36

but also for the case that somehow the image fails to load, 37

37

then on the website instead of the image appears this text, 38

38

so that users can still see 39

39

what the image that isn't there is all about. 40

40

So I'm just gonna put here logo. 41

41

I'm also going to add a class and call it just logo. 42

42

So we have a logo box and then logo. 43

43

So let's now style it. 44

44

So first the logo box. 45

45

And then the logo after that. 46

46

And remember where we want to put the image. 47

47

So it's here in this corner. 48

48

And so one good way of doing this 49

49

is to use absolute positioning. 50

50

And I'm once again sure that you already 51

51

know how absolute positioning works, 52

52

but in the next section there is a big lecture 53

53

which talks about the difference between 54

54

absolute and relative positioning, 55

55

and the normal flow and floats, 56

56

and all of that stuff, 57

57

so that you really understand how 58

58

all of this works behind the scenes. 59

59

Okay. 60

60

But for now, let's just simply use the position absolute, 61

61

like you already know how to do. 62

62

And we can then use top, bottom, left, and right properties 63

63

to put the image exactly where we want it to be. 64

64

So, let's say we want the top to be 40 pixels, 65

65

and the left to be 40 pixels. 66

66

Now, where does this measurement actually start? 67

67

So, from where, counting from where, is these 40 pixels? 68

68

And also these 40 pixels. 69

69

There has to be some kind of reference, right? 70

70

So, the place from which we start to count 40 pixels 71

71

to the left, and 40 pixels from the top. 72

72

Right? 73

73

And that reference is a parent element, 74

74

which has its position set to relative. 75

75

And so we should also do that. 76

76

And remember that the header is the parent element, right? 77

77

So, logo box and the parent is the header. 78

78

And so we should go to header 79

79

and set its position to relative. 80

80

Position relative. 81

81

So now this is the origin, so the reference, 82

82

from which top and left start to count. 83

83

Okay. 84

84

Now just before we check if this already looks good, 85

85

let's just specify the size of the image itself. 86

86

So we say height, 35 pixels. 87

87

That will be okay. 88

88

And then the width we'll scale accordingly. 89

89

So we don't even have to specify it. 90

90

All we do is to specify the height, 91

91

and the width will be automatically 92

92

figured out by the browser. 93

93

We could instead also set the width 94

94

and then the height would be figured out by the browser. 95

95

But I prefer to do it like this. 96

96

I always prefer to control the height of the elements. 97

97

So let's now take a look. 98

98

And indeed, there it is. 99

99

Okay. So this part is completed. 100

100

Let's now take care of this primary heading 101

101

that we have here. 102

102

So this one here, right. 103

103

So back to the HTML, 104

104

right after this logo box we will have our primary heading. 105

105

So I'm going to use the H one element, 106

106

and call it heading primary. 107

107

Alright. 108

108

Now, let's actually go back 109

109

to take a look at how we want this. 110

110

So we want this basically to have two parts. 111

111

So we have this entire text here, but this is all the H one. 112

112

Remember that the H one is the single most important 113

113

heading on the page, 114

114

which is important for Google or for any other search engine 115

115

to figure out what our webpage is all about. 116

116

And so it's important that we basically 117

117

put the title of our webpage in there. 118

118

Now we could only just put outdoors in there, 119

119

so make this the H one, and then for example, 120

120

make an H two here for the secondary header, 121

121

and put this is where life happens in there. 122

122

But that's not what we want, 123

123

because we don't want our primary text 124

124

or title of the website to say just outdoors. 125

125

We want all of this text. 126

126

And so we must somehow divide this text. 127

127

So, what are we going to do? 128

128

We are going to use this span element. 129

129

And this span element is perfect for this 130

130

because remember that a span 131

131

is simply to style some text different. 132

132

And so we can just put two span elements in here, 133

133

one for each part. 134

134

One for the top, and one for the bottom. 135

135

So span, class, heading, primary, main. 136

136

And then the same 137

137

for 138

138

the part on the bottom. 139

139

Let's call it sub. 140

140

So the first one says outdoors. 141

141

And down here, is where life happens. 142

142

So that's basically the slogan of the company. 143

143

And with that, we're good to go, and to format this text. 144

144

So, heading, primary, let me already copy it. 145

145

And then also 146

146

main, 147

147

and then also for the sub. 148

148

So the first thing that we want is the color to be white. 149

149

And that is just this fff code. 150

150

So in RGB fff is basically the same as saying this one here. 151

151

Okay. 152

152

And you see that both of them are the complete white. 153

153

So the presence of all the colors at the same time. 154

154

So it's complete red, complete green, and complete blue. 155

155

Okay. 156

156

But this is enough. 157

157

Now another thing that we want is to text the uppercase, 158

158

so we say text, transform, uppercase. 159

159

And for now that should be enough. 160

160

Let's just take a look. 161

161

And alright. 162

162

So our text is already here, it's already white. 163

163

It's not quite where we want it to be, 164

164

but we're gonna take care of that later. 165

165

Next, what we want to do, 166

166

is to put this on top, and this below it. 167

167

Right? 168

168

So we want outdoors on top, 169

169

and then after that this part here. 170

170

Also this text should be bigger, and this one smaller. 171

171

And also, as you see, it has this huge spacing here. 172

172

So I did this to make it look really big, 173

173

to give it some space to breathe. 174

174

I think this looks like outdoors. 175

175

It looks great with all this spacing. 176

176

That's why I decided to go this way. 177

177

Let's style it like this, 178

178

in the code here. 179

179

So, what should we do in order to put 180

180

these two parts of the text, one under another? 181

181

Do you have any idea of a good way of doing this? 182

182

I think the best way is to display 183

183

them both as block level elements. 184

184

Because remember that block elements 185

185

occupy the entire width that they have available. 186

186

And more importantly for this case, 187

187

they create line breaks after and before them. 188

188

And so that's exactly what we want. 189

189

So a span element is by default, an inline element. 190

190

So it's just like text. 191

191

And so we use the display property. 192

192

Display, and display it as a block. 193

193

Simple as that. 194

194

And the same thing down here for the other span element. 195

195

Display, and also block. 196

196

So that solves that part. 197

197

Now they need different font sizes. 198

198

So let's set this one to 60 pixels. 199

199

Give it a font white of 400. 200

200

Because by default, the H one has a higher font white, okay. 201

201

And then we also give it the letter spacing of, 202

202

let's say, 35 pixels. 203

203

Okay. And now similar specifications down here 204

204

for the sub-part of the H one. 205

205

So a font size in this case of 20 pixels, 206

206

font weight of 400 as well. 207

207

And the letter spacing, I'm going to put it to 15 pixels, 208

208

just to try it out, and if it doesn't look good, 209

209

we can always come back and adjust it. 210

210

So, I'm gonna reload. 211

211

And alright, it already looks pretty good. 212

212

Let's take a look at the inspector here, so, 213

213

to see what's happening here. 214

214

And indeed, so this is now a block, 215

215

and this is another block. 216

216

It occupies 100% of the width, 217

217

as you can see in the blue box, 218

218

exactly like a block element should behave. 219

219

And of course this also forces them into another line. 220

220

Now we need to slightly increase the letter spacing here. 221

221

So 17 looks good. 222

222

Maybe 17 five. 223

223

17 four. 224

224

Okay. 225

225

That looks about right. 226

226

So let's memorize this. 227

227

So 7.4. 228

228

And then also the weight of the font here 229

229

looks a bit too thin here compared to that one, okay. 230

230

So let's also increase that. 231

231

So the other spacing is 17.4. 232

232

17.4 pixels. 233

233

And now let's take a look at which weight 234

234

we actually have available. 235

235

So we have 100, 300, 400, 700, and 900. 236

236

So these are the font weight 237

237

that are loaded for this specific lotto font. 238

238

So we had 400, so let's now jump up to 700. 239

239

Taking a look again. 240

240

And yeah, so this looks much better now. 241

241

Alright. And with that formatted, 242

242

we should now find a way to make this displayed 243

243

exactly in the center. 244

244

Now of course, this should stay exactly in the center 245

245

no matter what the screen size is. 246

246

So no matter the width, 247

247

and no matter the height of the window, right. 248

248

No matter what height we have for the screen, 249

249

we always want this to stay in the middle. 250

250

Because of course, we're building a responsive website here. 251

251

And more about that later, again. 252

252

But for now, what we need to focus on, 253

253

is to put this text here, exactly here in the center. 254

254

So let's find out how we're gonna do that. 255

255

Now, first off, let's go back to our markup here in HTML, 256

256

because we're actually going to 257

257

put all of this in a different box, in a container, 258

258

because we're gonna add something more 259

259

into this box later on. 260

260

I can actually show you, 261

261

we're going to add this button here, 262

262

also in the same box, 263

263

which also should stay in the center by then. 264

264

Alright. 265

265

So we cannot just center this part here, 266

266

but we're going to center an entire box. 267

267

Like this. I'm going to show you. 268

268

So this entire box here 269

269

is what we're going to do, 270

270

and to center. 271

271

So, let's just call it 272

272

text box for now. 273

273

And then I'm gonna put all of this 274

274

inside. 275

275

So, text box is what we're gonna style next. 276

276

I'm putting it here just to follow 277

277

the natural order of the HTML. 278

278

So, text box. 279

279

So, what is the best way to exactly center that box 280

280

in the middle of our header? 281

281

And the answer is that, once again, 282

282

we're going to use absolute positioning. 283

283

Alright? 284

284

So, position absolute again. 285

285

Now about the top, and the left. 286

286

They will have to be a bit different. 287

287

And I'm going to show you how. 288

288

So, we start by saying top 50%, 289

289

and left 50%. 290

290

And just to illustrate this a bit better, 291

291

I will actually put a background color here, okay. 292

292

Background color. 293

293

Something, it doesn't really matter. 294

294

So I'm just putting red here. 295

295

And now I'm going to show you what happens. 296

296

Alright, so this is not quite where we want it to be. 297

297

Right? 298

298

But actually the code did what we wanted. 299

299

Because this here is clearly 50% from the left. 300

300

This part of the box. 301

301

Which is where the measure starts. 302

302

So where the 50% starts counting. 303

303

It's from this side, all the way to this side. 304

304

And it's 50%. 305

305

It's half of the element. 306

306

Half of the header. 307

307

That's what left 50% means. 308

308

It's 50% of the width of the parent element. 309

309

And it's actually working. 310

310

And the same thing applies to the top. 311

311

So it's from here to here, 312

312

it's actually 50%. 313

313

It's half of the height of the parent. 314

314

Now what we wanna do in order for this 315

315

to be exactly in the center, 316

316

is to shift this just a little bit, 317

317

so that the center of this box 318

318

is here in the center, is here. 319

319

That's where we want it. 320

320

So we want this middle of the box to be just here 321

321

where now the beginning of the box is. 322

322

And the same thing applies to the height. 323

323

So we want this center here of the box, 324

324

this horizontal center, 325

325

we want it to be here where the box now begins. 326

326

So another way, 327

327

what we want is to translate this entire box. 328

328

And it's actually pretty easy to do. 329

329

We just need to use the transform property in CSS. 330

330

Transform, and translate. 331

331

Translate. 332

332

And now we just need to specify how much we 333

333

wanna translate on x and on epsilon. 334

334

And what we want is minus 50% for both. 335

335

And that's it. 336

336

And that's because these 50% are now no longer 337

337

in relation to the parent element, 338

338

but of the element itself. 339

339

And so if we say we want minus 50%, 340

340

it will be shifted half of the width to the left side. 341

341

And the same for the height. 342

342

So minus 50% says that it will be shifted 343

343

50% of the element's height to the top. 344

344

And so, 345

345

and so here it is. 346

346

It's now exactly at the middle. 347

347

Vertically, 348

348

and also horizontally. 349

349

It's completely in the middle now. 350

350

Now because of this wedge that we cut out here, 351

351

it looks a bit weird. 352

352

It looks like it's actually more down 353

353

than where it should be, right? 354

354

It looks like it should be like somewhere here. 355

355

And so instead of shifting it down 50%, 356

356

maybe we can just do 40%. 357

357

We stated the top to be 40%, 358

358

and then that should fix our problem. 359

359

So this looks actually a lot better. 360

360

And just to confirm that everything works as expected, 361

361

we can just see that this nicely adapts 362

362

to when we decrease the screen size. 363

363

The same, we'll just do it like this, 364

364

the same happens with the view port height. 365

365

So it always stays nicely, 366

366

not exactly in the center, 367

367

but 368

368

at these 40% top 369

369

where we specified it to be. 370

370

Alright. 371

371

So you learned a great new trick. 372

372

Maybe you had already used it 373

373

because I taught it in my other course as well. 374

374

But I think I didn't explain it this well. 375

375

So I thought it was important 376

376

to make it really clear how this works. 377

377

Because it's really important. 378

378

You can now use these concepts for other things. 379

379

Because now you totally understand how this worked. 380

380

So again, just to make everything 100% sure. 381

381

These 40% and these 50%, 382

382

they are in relation to the parent element. 383

383

So 50% of the parent element 384

384

is where the text box was located to the left side. 385

385

But, on the transform here, when we translated, 386

386

this is in relation to the element itself. 387

387

And this makes it possible 388

388

that the element is exactly at the center. 389

389

Alright. 390

390

And that's enough for this lecture. 391

391

Next time, we're going to do this 392

392

little nice animation that we see here 393

393

when we reload the page. 394

394

So, this. 395

395

You saw it coming in from the left side, 396

396

and this one from the right side. 397

397

Let's do it again. 398

398

This entrance animation. 399

399

That's what we're going to do next, 400

400

which is really exciting I think. 401

401

So stay tuned and see you in a second.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.