All language subtitles for 004 [Project] CSS Flag_en

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 Download
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
fa Persian
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,050 --> 00:00:02,000 It's now time for the final project. 2 00:00:02,000 --> 00:00:08,480 And in this project, we're going to be building a flag of Laos using only CSS and HTML. 3 00:00:08,810 --> 00:00:12,700 If you take a look at this image, it looks like an oil painting, right? 4 00:00:12,710 --> 00:00:20,390 But actually, if you look behind the scenes, this is created completely just with HTML and CSS, which 5 00:00:20,390 --> 00:00:22,170 is completely crazy. 6 00:00:22,190 --> 00:00:28,670 If you head over to this URL (https://diana-adrianne.com/purecss-lace/), you'll see the portfolio of Diana Adrian, who is a CSS artist. 7 00:00:28,670 --> 00:00:35,780 And if you right-click on this image and you inspect it, you can see that all aspects of this painting 8 00:00:35,780 --> 00:00:41,600 is all created using CSS, which is completely mind blowing. 9 00:00:41,630 --> 00:00:47,720 For example, if we take a look at something really simple, the hair here, you can see there are like 10 00:00:47,720 --> 00:00:51,770 a million divs in here, each strand having a div. 11 00:00:51,770 --> 00:00:57,290 And then if you look inside each strand, you can see they've got border-radius set, width, height, 12 00:00:57,290 --> 00:00:58,760 different colors, etcetera. 13 00:00:58,760 --> 00:01:01,970 And it's this crazy complex CSS art. 14 00:01:02,300 --> 00:01:06,230 If you're not into oil paintings, then maybe you're into The Simpsons. 15 00:01:06,260 --> 00:01:13,520 These images of The Simpsons were all created using CSS, and if you head over to this URL (https://pattle.github.io/simpsons-in-css/), then you 16 00:01:13,520 --> 00:01:20,330 can actually click on each of these characters and you can see the CSS that was used to create them. 17 00:01:20,330 --> 00:01:25,370 And it's not surprising that it's a ton of CSS to write. 18 00:01:25,370 --> 00:01:27,710 So don't worry, this is not your challenge. 19 00:01:27,710 --> 00:01:33,920 We're not going to be creating something crazy like Krusty the Clown with 875 lines of CSS. 20 00:01:34,010 --> 00:01:37,010 It's just for you to be aware of the power of CSS. 21 00:01:37,010 --> 00:01:44,060 And once we learn the different ways of combining selectors, of the specificity of CSS selectors, 22 00:01:44,060 --> 00:01:50,540 positioning things, different properties, you can in fact eventually create crazy stuff like this, 23 00:01:50,570 --> 00:01:56,750 if you have a ton of time and probably an artistic streak as well. Most of the time when I work with 24 00:01:56,750 --> 00:02:02,160 CSS, my results look like this weird Pikachu where things are not positioned correctly and everything's 25 00:02:02,160 --> 00:02:04,440 just moving in the wrong directions. 26 00:02:04,440 --> 00:02:06,090 So you're not alone. 27 00:02:06,090 --> 00:02:09,720 Most people write CSS code that creates weird pikachus. 28 00:02:09,840 --> 00:02:16,170 The important thing is we understand why we get weird pikachus and why the eyeballs are so far down. 29 00:02:16,770 --> 00:02:21,930 So we're going to consolidate what we learned in this lesson by creating the flag of Laos. 30 00:02:21,930 --> 00:02:27,450 And this is going to test everything you've learned about combining different CSS selectors about CSS 31 00:02:27,450 --> 00:02:32,310 specificity, the CSS cascade, and also about positioning. 32 00:02:32,460 --> 00:02:37,950 And in the end, we will have this beautiful picture of the flag of Laos. 33 00:02:38,160 --> 00:02:41,400 Go ahead and download the starting project files and extract it. 34 00:02:41,430 --> 00:02:48,810 Now here, if you open up the index.html, you will see some very simple HTML that I've already set 35 00:02:48,810 --> 00:02:49,560 up for you. 36 00:02:49,560 --> 00:02:55,800 And if you preview it on the right, you'll see it has pretty much nothing, which is a great starting 37 00:02:55,800 --> 00:02:57,180 point for your project. 38 00:02:57,540 --> 00:03:05,940 The important thing is you don't change any of the HTML, so don't touch the index.html file at all. 39 00:03:05,940 --> 00:03:13,290 It's purposely vague in terms of classes and IDs and nothing is really tagged with anything. 40 00:03:13,290 --> 00:03:13,770 Right? 41 00:03:13,770 --> 00:03:17,790 And this is because we're doing a challenge, right? 42 00:03:17,790 --> 00:03:22,800 You can of course add loads of classes, loads of IDs and make this project super, super easy, 43 00:03:22,800 --> 00:03:25,800 but I want to test you on what you've learned so far. 44 00:03:25,800 --> 00:03:32,510 So that's why the initial index.html has basically nothing for you to be able to target with your selectors. 45 00:03:32,520 --> 00:03:35,580 Instead, you have to be a little bit more crafty. 46 00:03:35,610 --> 00:03:42,210 What we're aiming for is this. The flag doesn't have to be centered or positioned in any sort of particular 47 00:03:42,210 --> 00:03:42,750 way. 48 00:03:42,750 --> 00:03:48,120 This is going to be the top left corner, right here, and then there going to be a sort of rectangle that 49 00:03:48,120 --> 00:03:49,800 occupies part of your website. 50 00:03:49,800 --> 00:03:55,080 But the important thing is that it has these different aspects to it. 51 00:03:55,170 --> 00:04:02,580 It's got a red section here, which is 50% of this blue section here, and then it's got another red 52 00:04:02,580 --> 00:04:09,660 section down here, which is also similar in terms of how much it occupies and how it works is there 53 00:04:09,660 --> 00:04:17,970 is a big red div right here and above it there is this blue div on top. 54 00:04:18,480 --> 00:04:22,950 So that should already help you in terms of how this layout should look. 55 00:04:23,100 --> 00:04:29,850 Now the next thing is we've got a paragraph element that's located at the top and we've got another 56 00:04:29,850 --> 00:04:34,650 paragraph element that has to be inside a white circle. 57 00:04:35,160 --> 00:04:41,010 If you take a look inside the index.html, you'll notice that there are some hints in here, for example, 58 00:04:41,010 --> 00:04:47,880 the width and height of the flag and also the width and height of the circle. 59 00:04:48,180 --> 00:04:51,900 If you want to get hold of the precise colors. 60 00:04:51,900 --> 00:04:58,230 Remember previously we learned about CSS inspection and I've added a URL in here for you to be able 61 00:04:58,230 --> 00:04:59,880 to inspect on 62 00:04:59,910 --> 00:05:03,240 the actual image of the flag of Laos. 63 00:05:03,270 --> 00:05:06,480 This will test you on something you've learned previously as well. 64 00:05:06,510 --> 00:05:13,350 Remember, you can also right-click on the solution without opening the file and show it as a preview. 65 00:05:13,350 --> 00:05:19,500 And you can of course take the URL from VS Code and paste it inside your browser in order to see what 66 00:05:19,500 --> 00:05:21,210 the final outcome should look like 67 00:05:21,210 --> 00:05:25,530 so you can better compare your version versus this version. 68 00:05:25,920 --> 00:05:29,130 You can do this in many, many different ways. 69 00:05:29,130 --> 00:05:36,390 And the main thing I want to know is that you know how to combine selectors, you know, about CSS specificity 70 00:05:36,390 --> 00:05:39,220 and you know how to position things roughly on screen. 71 00:05:39,240 --> 00:05:42,450 Once you're ready, pause the video and complete the project. 72 00:05:45,450 --> 00:05:47,760 All right, let's go through the solution together. 73 00:05:47,790 --> 00:05:53,910 The first thing is to style the outermost div, which has a class of ".flag". 74 00:05:53,910 --> 00:05:58,110 So this is probably going to be the easiest part of this whole project. 75 00:05:58,260 --> 00:06:10,140 We can target that div and set it to be 900px wide and 600px high so that we have a rectangle. 76 00:06:10,260 --> 00:06:15,510 Now next we're going to have to set the background color so we can actually see it so that it's not 77 00:06:15,540 --> 00:06:16,350 white. 78 00:06:16,680 --> 00:06:22,800 In order to get the colors of the flag, remember I said we should inspect on it and then we can go 79 00:06:22,800 --> 00:06:26,790 into the three dots, more tools, CSS overview, 80 00:06:26,790 --> 00:06:29,820 and if we capture the overview, we'll get our hex codes. 81 00:06:29,820 --> 00:06:37,410 So the red, which is our first box, has this hex code, which I'm going to copy and then paste into 82 00:06:37,410 --> 00:06:37,920 here. 83 00:06:38,070 --> 00:06:44,530 And now we have a very large rectangle in our preview. 84 00:06:45,040 --> 00:06:49,960 Now the next step is to add this second rectangle on top of it. 85 00:06:50,260 --> 00:07:00,430 If we take a look at our HTML, you can see we've got a div with class flag as the highest, most div 86 00:07:00,430 --> 00:07:07,270 and then we've got as its children a paragraph element and another div and then we've got finally another 87 00:07:07,270 --> 00:07:08,920 div and a paragraph element. 88 00:07:08,920 --> 00:07:13,870 So this second div enclosed is going to be the one that we're going to turn blue. 89 00:07:14,650 --> 00:07:21,440 Remember I said we can't change any HTML so we can't add any classes or IDs to it. 90 00:07:21,460 --> 00:07:26,220 Instead, we're going to combine some selectors to select this particular div. 91 00:07:26,230 --> 00:07:29,140 So what is an identifying feature of it? 92 00:07:29,170 --> 00:07:37,510 Well, it is the direct descendant, the immediate child of this div class, so we can use the child 93 00:07:37,510 --> 00:07:45,520 combination by saying let's get the class ".flag" and then the angle bracket and then the child div. 94 00:07:45,520 --> 00:07:51,550 And in this div we're going to go ahead and give it a width and a height. 95 00:07:51,580 --> 00:07:55,480 The width, we want it to be 100% of its parent. 96 00:07:55,490 --> 00:08:00,430 So I'm just going to write 100% and it should end up being 900px. 97 00:08:00,460 --> 00:08:03,220 Alternatively, you can write the pixel number. 98 00:08:03,460 --> 00:08:09,430 Next, we're going to give it a height and I'm going to say 300px. 99 00:08:09,820 --> 00:08:14,920 This way it takes up exactly half the height of the big red pot. 100 00:08:15,460 --> 00:08:19,060 Now we just need to give it a background color in order to see it. 101 00:08:19,060 --> 00:08:22,210 And the color is going to be this blue color. 102 00:08:22,690 --> 00:08:23,800 And there we have it. 103 00:08:23,830 --> 00:08:27,880 We have a blue rectangle inside a red rectangle. 104 00:08:28,570 --> 00:08:33,640 Before we get busy positioning things, let's just make sure that we've got everything on screen first. 105 00:08:33,640 --> 00:08:35,860 So I want the circle to show up. 106 00:08:35,860 --> 00:08:40,630 And coming back to our HTML, you can see we've got one div. 107 00:08:40,659 --> 00:08:43,059 This is the red rectangle. 108 00:08:43,059 --> 00:08:46,270 Inside there's another div which is the blue rectangle. 109 00:08:46,270 --> 00:08:51,370 And finally inside that we've got another div which we're going to turn into the circle. 110 00:08:51,520 --> 00:08:54,340 How do we get hold of this one? 111 00:08:54,850 --> 00:09:03,160 Well, we could use the descendant selector because this div is the immediate child of this div, which 112 00:09:03,160 --> 00:09:04,440 is then a child of this div. 113 00:09:04,450 --> 00:09:14,080 So we're saying it's three levels down and we can do that by saying the ".flag" class has a child, which 114 00:09:14,080 --> 00:09:21,880 is a div which has another child, which is a div and this particular div we're going to give it a width 115 00:09:21,910 --> 00:09:31,390 of 200px and a height of 200px and we're going to give it a background color of white. 116 00:09:31,510 --> 00:09:34,120 And we should now see a little square here. 117 00:09:34,210 --> 00:09:39,220 And in order to turn it into a circle, we set the border-radius to 50%. 118 00:09:39,910 --> 00:09:45,460 So now we've got all three shapes on screen and it's time to try and position them so they look a bit 119 00:09:45,460 --> 00:09:46,660 more like this. 120 00:09:47,850 --> 00:09:56,010 Notice that this blue rectangle is not only half the size of the rectangle, but it's also shifted down 121 00:09:56,010 --> 00:09:57,450 by a quarter. 122 00:09:57,600 --> 00:10:00,150 So we want to set its position. 123 00:10:00,750 --> 00:10:08,790 Now, as I mentioned, in order to set the position of an element relative to a parent, what you need 124 00:10:08,820 --> 00:10:10,980 is for the child element, 125 00:10:10,980 --> 00:10:18,900 so in this case, this rectangle that's inside this blue rectangle that's inside the red rectangle, to 126 00:10:18,900 --> 00:10:22,080 have a position type of absolute. 127 00:10:23,040 --> 00:10:34,950 And then if its parent has a position type of relative, then we can now set this blue rectangle relative 128 00:10:34,980 --> 00:10:37,590 to this red rectangle. 129 00:10:40,040 --> 00:10:50,210 So we can say from the top, let's shift it down by 150px, which is a quarter of 900px, 130 00:10:51,560 --> 00:10:57,470 even though we set this red rectangle to have position relative and we didn't move it at all, 131 00:10:57,500 --> 00:11:05,720 by setting it to relative, it enables us to modify the children's position relative to that parent. 132 00:11:05,840 --> 00:11:12,020 And this is why you'll very commonly see this structure, a parent having position relative and a child 133 00:11:12,020 --> 00:11:14,070 having position absolute. 134 00:11:14,090 --> 00:11:19,100 And then we move it relative to the parent using the same strategy. 135 00:11:19,100 --> 00:11:21,440 We can do the same thing for our circle. 136 00:11:21,470 --> 00:11:30,290 Because our circle basically has to be in the middle of the red rectangle if we set the position of 137 00:11:30,290 --> 00:11:32,510 this white circle. 138 00:11:34,300 --> 00:11:40,610 To be positioned relative, then we can set it relative to its parent, which is the blue rectangle. 139 00:11:40,630 --> 00:11:46,720 So in order to move it to the center of the blue rectangle, we have to shift it down so from the top 140 00:11:46,720 --> 00:11:53,560 by 50px, because if we know that this height is 300px, 141 00:11:55,380 --> 00:11:59,040 then half of it is going to be 150. 142 00:12:00,150 --> 00:12:09,390 So then if we know that the radius of the circle is 100px because it's got a total height of 200 143 00:12:09,390 --> 00:12:17,100 and a width of 200, then we know that in order for it to be in the center, it needs to be 50px 144 00:12:17,100 --> 00:12:18,450 from the top. 145 00:12:20,160 --> 00:12:26,970 And by similar calculation, we can work out that it needs to be 350px from the left. 146 00:12:27,750 --> 00:12:33,540 Even though we did all our calculations correctly, you can see this white circle doesn't quite look 147 00:12:33,540 --> 00:12:37,470 like it's right in the middle of this blue rectangle, right? 148 00:12:37,470 --> 00:12:45,540 It's a little bit shifted to the lower part so we can diagnose our issues using pesticide. 149 00:12:45,930 --> 00:12:52,860 In this case, you can see that we've got a div here, but we've also got a box above it and this is 150 00:12:52,860 --> 00:12:54,600 the paragraph element. 151 00:12:54,600 --> 00:13:00,540 And if we go ahead and inspect it inside the Chrome inspector, you can see that paragraph element has 152 00:13:00,540 --> 00:13:02,910 a margin top and margin bottom. 153 00:13:03,130 --> 00:13:06,390 If I go ahead and delete both of those margins, 154 00:13:07,360 --> 00:13:10,720 then you can see our circle shifts bang into the middle. 155 00:13:10,840 --> 00:13:17,740 So it's actually the margin around the paragraph element that's actually pushing the circle down because 156 00:13:17,740 --> 00:13:25,390 it is within the flow of the HTML because by default, all elements are statically placed in the flow 157 00:13:25,390 --> 00:13:26,370 of HTML. 158 00:13:26,980 --> 00:13:29,650 Let's go ahead and implement that in our code. 159 00:13:29,650 --> 00:13:35,020 We can select all the paragraph elements and set their margin to zero. 160 00:13:35,020 --> 00:13:40,510 And you can see immediately our circle is now centered in the screen. 161 00:13:41,110 --> 00:13:47,050 In addition, if we look at the goal image, we want to have the text super large. 162 00:13:47,080 --> 00:13:54,520 You can play around with the font size, but the one that I used is 5rem and this will get you pretty 163 00:13:54,520 --> 00:13:56,710 much the same size that you see here. 164 00:13:57,310 --> 00:14:03,460 In addition, the text is centered both inside the circle and at the top. 165 00:14:03,460 --> 00:14:10,220 So we need to set our text align to center and that gets it pretty much where it needs to be. 166 00:14:11,060 --> 00:14:17,900 Now, the very last thing we need to do is to change the color of this part to white and this part to 167 00:14:17,900 --> 00:14:18,680 black. 168 00:14:18,830 --> 00:14:27,920 One way that we could do it is to simply set the color for all the text to white, and this will turn 169 00:14:27,920 --> 00:14:33,050 everything white and will no longer be able to see this text even though it does exist. 170 00:14:33,470 --> 00:14:40,190 And if we wanted to select that particular paragraph element, we don't have a good way of selecting 171 00:14:40,190 --> 00:14:45,020 it with class or ID because we're not letting you change this HTML. 172 00:14:45,020 --> 00:14:49,030 But you can of course use different combinations to get there. 173 00:14:49,040 --> 00:14:56,540 For example, this paragraph element is a child of a div of another div of another div of a body. 174 00:14:56,600 --> 00:14:59,120 There's actually a cheat code to doing this. 175 00:14:59,150 --> 00:15:05,180 If we open up the inspector and find that paragraph element, we want to select right click on it, 176 00:15:05,180 --> 00:15:08,180 go to copy and then copy selector. 177 00:15:08,180 --> 00:15:17,060 And once you paste it in here, you'll see it's actually the selector that will allow us to target that 178 00:15:17,060 --> 00:15:19,910 exact bit that we wanted to. 179 00:15:20,660 --> 00:15:26,750 I don't recommend blindly copy and pasting things, so this is a little bit of a cheat code, but because 180 00:15:26,750 --> 00:15:31,040 we now understand how this works, we can actually simplify this massively. 181 00:15:31,040 --> 00:15:38,300 We know that what it's saying is find the body, find its child, that's a div, find its child, that's 182 00:15:38,300 --> 00:15:41,060 div and then another child and then three levels deep, 183 00:15:41,060 --> 00:15:48,680 there should be a paragraph tag which needs to be black. Because we understand this, we can vastly simplify 184 00:15:48,680 --> 00:15:50,480 it by getting rid of that body, 185 00:15:50,480 --> 00:15:55,730 or we could change this to the class ".flag", which would do exactly the same. 186 00:15:55,730 --> 00:16:01,550 And we can even swap out these child symbols and keep it as a descendant selector. 187 00:16:01,550 --> 00:16:08,330 So a paragraph element that is a child of this div, a grandchild of another div and a great-grandchild 188 00:16:08,330 --> 00:16:12,500 of something that has this class, we'll select it and make it black. 189 00:16:13,130 --> 00:16:16,730 This is a little bit of a roundabout way of achieving the goal. 190 00:16:16,730 --> 00:16:18,500 You might have done something completely different. 191 00:16:18,500 --> 00:16:21,800 For example, we know that by default everything is black. 192 00:16:21,800 --> 00:16:26,360 So you could have also selected this paragraph element and turn it white instead. 193 00:16:26,360 --> 00:16:33,500 But I just wanted to demo to you a neat feature of Chrome Inspector show you the cheat code after you've 194 00:16:33,500 --> 00:16:40,610 done the exercise and let you know that this is also a possible way that you could try out in the future. 195 00:16:41,120 --> 00:16:48,080 So now if we compare our flag with the solution flag, you can see it's completely identical. 196 00:16:48,110 --> 00:16:52,930 Now, it might not be for you because maybe you've used a different method for positioning. 197 00:16:52,940 --> 00:16:58,760 Maybe you've changed the font size to a different font size, but essentially you should be close to 198 00:16:58,760 --> 00:17:04,460 this layout and hopefully in the process you've managed to use some of the skills that you learned in 199 00:17:04,460 --> 00:17:05,510 this section. 200 00:17:05,720 --> 00:17:13,730 The inspiration for this project comes from a website I came across by Michael Lascarides, and he basically 201 00:17:13,730 --> 00:17:19,329 classified world flags in order of difficulty to draw. 202 00:17:19,339 --> 00:17:25,339 So you can see all the way down here there is Serbia, which is pretty much the most complex flag to 203 00:17:25,339 --> 00:17:27,380 draw because of the shield. 204 00:17:27,380 --> 00:17:30,560 And there are other countries like Croatia or Mexico. 205 00:17:30,560 --> 00:17:37,490 But at the very top there are the simplest flags, for example, Palau or Nigeria or Peru. 206 00:17:37,520 --> 00:17:42,900 So if you want to have a go drawing your own country's flag, hopefully you're not in Serbia. 207 00:17:42,900 --> 00:17:44,970 If you are, then good luck. 208 00:17:44,970 --> 00:17:50,610 But if you're based in Austria or Bangladesh, then this should be quite doable using the skills that 209 00:17:50,610 --> 00:17:52,170 you've learnt with CSS. 210 00:17:52,560 --> 00:17:54,960 Enjoy, and I'll see you on the next section. 22869

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