All language subtitles for 0005 - CSS Box Model Tutorial for Beginners.en.clean

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) Download
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
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,910 --> 00:00:05,030 [Music] 2 00:00:05,040 --> 00:00:07,190 hello and welcome hi i'm dave this 3 00:00:07,200 --> 00:00:09,350 tutorial is part of a beginner css 4 00:00:09,360 --> 00:00:11,589 series i'll be using the chrome web 5 00:00:11,599 --> 00:00:14,310 browser the visual studio code editor 6 00:00:14,320 --> 00:00:16,230 and the live server extension for visual 7 00:00:16,240 --> 00:00:18,630 studio code to view the web page 8 00:00:18,640 --> 00:00:20,630 there are links to these tools starter 9 00:00:20,640 --> 00:00:23,029 code files and all resources in the 10 00:00:23,039 --> 00:00:25,269 description below 11 00:00:25,279 --> 00:00:27,990 let's move on to the css box model today 12 00:00:28,000 --> 00:00:30,310 you'll learn that everything in css is a 13 00:00:30,320 --> 00:00:32,549 box but before we finish i'll show you 14 00:00:32,559 --> 00:00:34,470 how to turn a box into a circle if you 15 00:00:34,480 --> 00:00:37,110 want to so let's get started on the left 16 00:00:37,120 --> 00:00:39,590 i have visual studio code and i have the 17 00:00:39,600 --> 00:00:41,830 code from the last tutorial we'll modify 18 00:00:41,840 --> 00:00:44,470 that in just a second on the right i 19 00:00:44,480 --> 00:00:47,190 have a basic web page once again with an 20 00:00:47,200 --> 00:00:50,549 h1 header and a paragraph and i'm using 21 00:00:50,559 --> 00:00:53,270 the live server extension so any changes 22 00:00:53,280 --> 00:00:56,229 i make in the css and when i save the 23 00:00:56,239 --> 00:00:58,709 file will immediately show then in the 24 00:00:58,719 --> 00:01:01,510 web page okay so everything we have over 25 00:01:01,520 --> 00:01:04,070 here except the h1 has got to go so i'm 26 00:01:04,080 --> 00:01:06,230 going to delete everything above 27 00:01:06,240 --> 00:01:07,590 and below 28 00:01:07,600 --> 00:01:09,830 and leave the styles for the h1 and we 29 00:01:09,840 --> 00:01:12,469 can now save and we see those changes so 30 00:01:12,479 --> 00:01:13,910 our paragraph 31 00:01:13,920 --> 00:01:15,990 text has gotten smaller 32 00:01:16,000 --> 00:01:18,310 and everything else is pretty much the 33 00:01:18,320 --> 00:01:20,390 same except we do now have the default 34 00:01:20,400 --> 00:01:22,870 styles from the browser again and we'll 35 00:01:22,880 --> 00:01:25,990 get back to that css reset in just a bit 36 00:01:26,000 --> 00:01:27,590 but right now we want to look at this 37 00:01:27,600 --> 00:01:30,230 box model and we've already drawn a box 38 00:01:30,240 --> 00:01:32,950 by putting a border around our h1 39 00:01:32,960 --> 00:01:34,710 element we can see this border here 40 00:01:34,720 --> 00:01:36,630 defined with shorthand and we'll get 41 00:01:36,640 --> 00:01:39,190 into what all of that means in just a 42 00:01:39,200 --> 00:01:41,830 second too but what i want to do first 43 00:01:41,840 --> 00:01:43,270 is drag 44 00:01:43,280 --> 00:01:45,590 our visual studio code over as far as i 45 00:01:45,600 --> 00:01:47,590 possibly can and give us some more room 46 00:01:47,600 --> 00:01:48,950 in the browser because we're going to 47 00:01:48,960 --> 00:01:51,510 open up dev tools so once you do that 48 00:01:51,520 --> 00:01:54,950 you can press shift alt or i'm sorry not 49 00:01:54,960 --> 00:01:57,670 shift alt it is control shift i believe 50 00:01:57,680 --> 00:01:59,030 and the letter i 51 00:01:59,040 --> 00:02:00,950 to open dev tools 52 00:02:00,960 --> 00:02:02,950 and if that's not working then you 53 00:02:02,960 --> 00:02:04,550 should be able to no that is going to 54 00:02:04,560 --> 00:02:06,230 work it just took a second here on my 55 00:02:06,240 --> 00:02:07,350 computer 56 00:02:07,360 --> 00:02:09,109 and if that doesn't work you could right 57 00:02:09,119 --> 00:02:11,589 click and choose inspect as well once 58 00:02:11,599 --> 00:02:13,589 you have it open you may not have your 59 00:02:13,599 --> 00:02:15,350 dev tools on the right and if you don't 60 00:02:15,360 --> 00:02:17,430 you can click the three dots and choose 61 00:02:17,440 --> 00:02:19,510 where it is docked i like to have mine 62 00:02:19,520 --> 00:02:22,470 on the right and then you can select any 63 00:02:22,480 --> 00:02:25,030 of the elements in the html here and you 64 00:02:25,040 --> 00:02:26,869 see it flashing over on the web page 65 00:02:26,879 --> 00:02:28,470 because it highlights what element 66 00:02:28,480 --> 00:02:31,350 you've selected and i am in the elements 67 00:02:31,360 --> 00:02:33,509 tab that you can choose as well 68 00:02:33,519 --> 00:02:36,150 after that i am going to select that h1 69 00:02:36,160 --> 00:02:37,990 so it's inside of our header element 70 00:02:38,000 --> 00:02:38,790 here 71 00:02:38,800 --> 00:02:40,630 and after i select it i've got h1 and 72 00:02:40,640 --> 00:02:42,470 notice the colors changed on the web 73 00:02:42,480 --> 00:02:45,350 page this is already showing us the box 74 00:02:45,360 --> 00:02:48,390 model right here so what we have for the 75 00:02:48,400 --> 00:02:50,949 orange is the margin and then we can 76 00:02:50,959 --> 00:02:53,270 clearly see our border that we put in 77 00:02:53,280 --> 00:02:56,229 with two pixels and it is dashed and 78 00:02:56,239 --> 00:02:58,869 then inside of that we see green and 79 00:02:58,879 --> 00:03:01,190 that is the padding and then inside of 80 00:03:01,200 --> 00:03:03,110 that we see blue and that's actually the 81 00:03:03,120 --> 00:03:06,149 content and now if we go down here where 82 00:03:06,159 --> 00:03:07,990 we have a styles tab let's choose the 83 00:03:08,000 --> 00:03:11,190 computed tab and we actually see the box 84 00:03:11,200 --> 00:03:13,670 model inside of our dev tools so we can 85 00:03:13,680 --> 00:03:15,509 highlight any aspect of this so i'll go 86 00:03:15,519 --> 00:03:18,149 to the content first and now we only see 87 00:03:18,159 --> 00:03:20,309 the blue highlighted on the web page and 88 00:03:20,319 --> 00:03:22,149 that is our content and it's showing us 89 00:03:22,159 --> 00:03:25,110 the actual size of the content in pixels 90 00:03:25,120 --> 00:03:27,589 here as well and then we go to padding 91 00:03:27,599 --> 00:03:29,589 which is the next layer the padding is 92 00:03:29,599 --> 00:03:32,470 once again inside of the border and it 93 00:03:32,480 --> 00:03:34,470 just wraps around our content it gives 94 00:03:34,480 --> 00:03:37,670 some extra space inside of the border 95 00:03:37,680 --> 00:03:39,270 gives our content a little room to 96 00:03:39,280 --> 00:03:41,110 breathe if you will so here you can see 97 00:03:41,120 --> 00:03:44,470 it's 24 pixels then we have our border 98 00:03:44,480 --> 00:03:46,190 which it shows it as 99 00:03:46,200 --> 00:03:49,509 1.993 pixels we set it to 2 pixels hey 100 00:03:49,519 --> 00:03:52,390 close enough right and after the border 101 00:03:52,400 --> 00:03:55,110 we have margin and you can see we didn't 102 00:03:55,120 --> 00:03:57,589 set a margin so this margin is just 103 00:03:57,599 --> 00:04:01,030 showing the space that is left after our 104 00:04:01,040 --> 00:04:04,470 element is there so on top we have 32 105 00:04:04,480 --> 00:04:07,589 pixels and then we have 32 pixels on the 106 00:04:07,599 --> 00:04:10,309 bottom as well and that's probably just 107 00:04:10,319 --> 00:04:12,630 because of the default of the h1 we 108 00:04:12,640 --> 00:04:14,949 didn't set a margin on the right but we 109 00:04:14,959 --> 00:04:17,110 do see a big margin over there and 110 00:04:17,120 --> 00:04:19,990 that's just because we have set that 50 111 00:04:20,000 --> 00:04:22,790 percent width on our h1 so it's not 112 00:04:22,800 --> 00:04:26,230 taking up the full page space and what's 113 00:04:26,240 --> 00:04:28,390 left is occupied by margin 114 00:04:28,400 --> 00:04:29,990 so it's important that you remember how 115 00:04:30,000 --> 00:04:31,990 to get here in dev tools we're on this 116 00:04:32,000 --> 00:04:34,469 computed tab below and you always want 117 00:04:34,479 --> 00:04:36,310 to be able to bring up the box model to 118 00:04:36,320 --> 00:04:38,070 see exactly what's going on with your 119 00:04:38,080 --> 00:04:40,469 elements after that it's also important 120 00:04:40,479 --> 00:04:43,110 to just memorize the different layers of 121 00:04:43,120 --> 00:04:45,670 the css box model so starting on the 122 00:04:45,680 --> 00:04:48,230 inside we have content then we have 123 00:04:48,240 --> 00:04:51,189 padding then we have border and finally 124 00:04:51,199 --> 00:04:53,670 we have margin on the outside and now 125 00:04:53,680 --> 00:04:55,830 concerning our h1 and the margin that i 126 00:04:55,840 --> 00:04:58,550 have highlighted notice it's 32 pixels 127 00:04:58,560 --> 00:04:59,310 actually 128 00:04:59,320 --> 00:05:02,790 32.16 pixels and we didn't set that so 129 00:05:02,800 --> 00:05:05,590 that's a default style on the h1 we've 130 00:05:05,600 --> 00:05:08,469 got the h1 selected let's go back to the 131 00:05:08,479 --> 00:05:11,189 styles tab instead of the computed tab 132 00:05:11,199 --> 00:05:13,189 and we can see this if we scroll just a 133 00:05:13,199 --> 00:05:15,270 little bit there's the styles we set and 134 00:05:15,280 --> 00:05:17,670 then here are the default styles from 135 00:05:17,680 --> 00:05:20,150 the browser this is a user agent style 136 00:05:20,160 --> 00:05:22,550 sheet that's assigned by the browser and 137 00:05:22,560 --> 00:05:25,110 here you can see they assigned some 138 00:05:25,120 --> 00:05:28,870 margin settings here it's 0.67 139 00:05:28,880 --> 00:05:32,390 em so that's essentially two-thirds now 140 00:05:32,400 --> 00:05:35,510 if we remember about our units an e-m 141 00:05:35,520 --> 00:05:38,790 responds to the font size of the element 142 00:05:38,800 --> 00:05:41,670 and we set a font size of three rim 143 00:05:41,680 --> 00:05:45,110 which would essentially be 48 pixels so 144 00:05:45,120 --> 00:05:47,110 two-thirds of that is coming in right 145 00:05:47,120 --> 00:05:49,110 around where we see it on our box model 146 00:05:49,120 --> 00:05:51,749 here at 147 00:05:51,759 --> 00:05:54,390 pixels so now that we know our font size 148 00:05:54,400 --> 00:05:56,710 is impacting the default margin let's go 149 00:05:56,720 --> 00:05:59,110 ahead and change our font size and of 150 00:05:59,120 --> 00:06:00,870 course it will also change our padding 151 00:06:00,880 --> 00:06:03,510 that we based on em units i'm going to 152 00:06:03,520 --> 00:06:05,029 change this to 153 00:06:05,039 --> 00:06:08,550 to rim if i can type here to rim and 154 00:06:08,560 --> 00:06:09,510 save 155 00:06:09,520 --> 00:06:12,230 and now things have changed notice our 156 00:06:12,240 --> 00:06:14,350 margin got smaller it's 157 00:06:14,360 --> 00:06:17,830 21.44 because our font size got smaller 158 00:06:17,840 --> 00:06:21,670 and this is based on an em unit an m 159 00:06:21,680 --> 00:06:23,990 as far as the browser is concerned so 160 00:06:24,000 --> 00:06:27,430 once again it's still 0.67 em 161 00:06:27,440 --> 00:06:30,510 but the actual size is smaller it's 162 00:06:30,520 --> 00:06:33,430 21.44 pixels now changes like this can 163 00:06:33,440 --> 00:06:35,510 be really hard to keep track of and so 164 00:06:35,520 --> 00:06:37,350 that's why sometimes we just want to 165 00:06:37,360 --> 00:06:40,790 reset the browser settings for all the 166 00:06:40,800 --> 00:06:42,629 margins and all the padding and just 167 00:06:42,639 --> 00:06:45,110 take control of them ourselves and 168 00:06:45,120 --> 00:06:48,309 that's why we use a css reset and a very 169 00:06:48,319 --> 00:06:51,350 basic css restart starts with the wild 170 00:06:51,360 --> 00:06:54,150 card at the top and then we set margin 171 00:06:54,160 --> 00:06:55,990 for all elements because remember this 172 00:06:56,000 --> 00:06:58,710 wild card selects all elements so we set 173 00:06:58,720 --> 00:07:00,629 the margin to zero 174 00:07:00,639 --> 00:07:03,189 and we set the padding to zero 175 00:07:03,199 --> 00:07:05,990 and we can save and now all of that 176 00:07:06,000 --> 00:07:07,749 margin and padding that is set by 177 00:07:07,759 --> 00:07:09,830 default is taken away and you can see 178 00:07:09,840 --> 00:07:12,469 the body actually had a little bit of 179 00:07:12,479 --> 00:07:14,550 margin set to it as well because now 180 00:07:14,560 --> 00:07:16,390 we're right up to the edge of the body 181 00:07:16,400 --> 00:07:19,029 here on our page and this border we set 182 00:07:19,039 --> 00:07:20,629 around our h1 183 00:07:20,639 --> 00:07:22,469 is right up to the edge of the page as 184 00:07:22,479 --> 00:07:24,790 well and there's one more setting i 185 00:07:24,800 --> 00:07:27,589 always put inside of the css reset and 186 00:07:27,599 --> 00:07:29,350 that is box 187 00:07:29,360 --> 00:07:31,749 dash sizing there we go 188 00:07:31,759 --> 00:07:33,589 and now the default 189 00:07:33,599 --> 00:07:37,110 is content box and if we save we won't 190 00:07:37,120 --> 00:07:38,950 really notice a change here it didn't 191 00:07:38,960 --> 00:07:41,350 really change anything because that is 192 00:07:41,360 --> 00:07:44,629 the default so what the content box does 193 00:07:44,639 --> 00:07:46,869 is it says okay the size that we're 194 00:07:46,879 --> 00:07:49,510 setting is this for the content and the 195 00:07:49,520 --> 00:07:52,070 content only it doesn't include 196 00:07:52,080 --> 00:07:54,790 calculating the size of the padding or 197 00:07:54,800 --> 00:07:57,670 of the border or of the margin at all so 198 00:07:57,680 --> 00:07:59,270 instead of 50 199 00:07:59,280 --> 00:08:01,350 i'm going to set an absolute width on 200 00:08:01,360 --> 00:08:03,909 here so we can compare and i'll set this 201 00:08:03,919 --> 00:08:05,350 to say 202 00:08:05,360 --> 00:08:09,430 400 pixels and save now let's look over 203 00:08:09,440 --> 00:08:11,909 here in our box and we can see the 204 00:08:11,919 --> 00:08:15,029 content is 400 pixels but that doesn't 205 00:08:15,039 --> 00:08:17,270 account for the padding what we have 206 00:08:17,280 --> 00:08:19,589 here is not the 400 pixels we were 207 00:08:19,599 --> 00:08:21,830 expecting we took up more space than 208 00:08:21,840 --> 00:08:25,110 that but if we set this to border box 209 00:08:25,120 --> 00:08:27,189 instead of content box 210 00:08:27,199 --> 00:08:29,589 then we'll get what we expect and it's 211 00:08:29,599 --> 00:08:31,830 much easier to calculate so now notice 212 00:08:31,840 --> 00:08:34,790 our content over here is not 400 pixels 213 00:08:34,800 --> 00:08:36,949 is 348 214 00:08:36,959 --> 00:08:38,709 and then we can add in 215 00:08:38,719 --> 00:08:42,550 24 pixels of padding on each side and 216 00:08:42,560 --> 00:08:45,829 two pixels of border on each side and 217 00:08:45,839 --> 00:08:48,550 then we can get our total of 400. so 218 00:08:48,560 --> 00:08:51,030 what borderbox does is it really helps 219 00:08:51,040 --> 00:08:53,670 us calculate the sizes that we are 220 00:08:53,680 --> 00:08:55,430 assigning because it goes ahead and 221 00:08:55,440 --> 00:08:57,670 includes the border and the padding it 222 00:08:57,680 --> 00:08:59,910 does not include the margin the margin 223 00:08:59,920 --> 00:09:02,070 is on the outside 224 00:09:02,080 --> 00:09:04,949 of our css boxes that we create 225 00:09:04,959 --> 00:09:06,870 whichever elements that we are styling 226 00:09:06,880 --> 00:09:08,870 so the margin is not included in that 227 00:09:08,880 --> 00:09:11,829 calculation however the rest is so the 228 00:09:11,839 --> 00:09:14,150 border and the padding and the content 229 00:09:14,160 --> 00:09:16,550 all add up to that 400 pixels that i set 230 00:09:16,560 --> 00:09:18,550 right here okay now that we've broken 231 00:09:18,560 --> 00:09:21,190 down how the border box setting works 232 00:09:21,200 --> 00:09:24,310 and looked at the css box model let's go 233 00:09:24,320 --> 00:09:26,790 ahead and close devtools and let's just 234 00:09:26,800 --> 00:09:28,710 style our page a little bit with some of 235 00:09:28,720 --> 00:09:30,550 these properties i'm going to resize the 236 00:09:30,560 --> 00:09:32,070 page a little bit so we have some more 237 00:09:32,080 --> 00:09:33,910 room for visual studio code over here on 238 00:09:33,920 --> 00:09:37,190 the left i'll pull this over there we go 239 00:09:37,200 --> 00:09:39,750 and now let's make some changes so one 240 00:09:39,760 --> 00:09:42,150 thing i have thought about is our h1 241 00:09:42,160 --> 00:09:44,310 right here has some settings i normally 242 00:09:44,320 --> 00:09:46,310 probably wouldn't put on an h1 i'm just 243 00:09:46,320 --> 00:09:48,870 more concerned with the font there but 244 00:09:48,880 --> 00:09:51,350 the font size that would be assigned by 245 00:09:51,360 --> 00:09:53,590 default is okay too so i'm going to get 246 00:09:53,600 --> 00:09:56,550 rid of that and now these other settings 247 00:09:56,560 --> 00:09:58,949 i would actually be more likely to put 248 00:09:58,959 --> 00:10:01,910 on the container than i would on the h1 249 00:10:01,920 --> 00:10:04,550 itself and the h1 is inside of a header 250 00:10:04,560 --> 00:10:07,509 element so let's go ahead and save that 251 00:10:07,519 --> 00:10:09,670 and it changed just a little bit but 252 00:10:09,680 --> 00:10:11,670 that's okay i'm going to change these 253 00:10:11,680 --> 00:10:14,550 ems back to rims because now i'm not 254 00:10:14,560 --> 00:10:16,470 setting a font size on the header so i'm 255 00:10:16,480 --> 00:10:19,110 going to use 1.5 rim here 256 00:10:19,120 --> 00:10:21,509 and save and now we've got our padding 257 00:10:21,519 --> 00:10:23,430 back to about where it was but now what 258 00:10:23,440 --> 00:10:25,430 if i wanted to assign these same 259 00:10:25,440 --> 00:10:27,269 settings to the container that our 260 00:10:27,279 --> 00:10:29,269 paragraph is in and that's in the main 261 00:10:29,279 --> 00:10:31,590 element so maybe i don't want this on 262 00:10:31,600 --> 00:10:33,829 the header maybe i want to assign a 263 00:10:33,839 --> 00:10:36,470 container class so i can provide these 264 00:10:36,480 --> 00:10:37,990 same settings for more than one 265 00:10:38,000 --> 00:10:39,670 container so i'm going to quickly go 266 00:10:39,680 --> 00:10:41,590 over to the html 267 00:10:41,600 --> 00:10:44,310 and in the html we'll set a class called 268 00:10:44,320 --> 00:10:46,949 container on each of these elements so 269 00:10:46,959 --> 00:10:49,110 we have the header element 270 00:10:49,120 --> 00:10:51,269 and we'll set the class equal to 271 00:10:51,279 --> 00:10:52,630 container 272 00:10:52,640 --> 00:10:56,230 and i've got one extra 273 00:10:56,240 --> 00:10:58,389 quote there there we go and now i'm just 274 00:10:58,399 --> 00:11:00,630 going to copy this and i'll paste it 275 00:11:00,640 --> 00:11:01,990 into our 276 00:11:02,000 --> 00:11:05,430 main element as well 277 00:11:05,440 --> 00:11:08,069 and save that and there we go so now 278 00:11:08,079 --> 00:11:10,069 we've got dashes around both of these 279 00:11:10,079 --> 00:11:13,190 boxes here let's go back to the css and 280 00:11:13,200 --> 00:11:15,030 make these bigger so we can see them 281 00:11:15,040 --> 00:11:17,030 better on the page right now i'm going 282 00:11:17,040 --> 00:11:19,590 to get rid of this 100 pixel or 400 283 00:11:19,600 --> 00:11:21,990 pixel width let's go ahead and let them 284 00:11:22,000 --> 00:11:25,030 take up the full 100 percent for now 285 00:11:25,040 --> 00:11:27,350 okay let's go ahead and add a font size 286 00:11:27,360 --> 00:11:29,269 to the container and it will apply to 287 00:11:29,279 --> 00:11:30,949 both of these differently but we'll set 288 00:11:30,959 --> 00:11:32,790 it to 1.5 289 00:11:32,800 --> 00:11:34,630 rim and save 290 00:11:34,640 --> 00:11:36,870 now our fonts a little bit bigger but 291 00:11:36,880 --> 00:11:38,870 notice how the edges of the border are 292 00:11:38,880 --> 00:11:41,269 right up against the page so on the 293 00:11:41,279 --> 00:11:44,310 outside of our box we can set a margin 294 00:11:44,320 --> 00:11:47,750 and also set that to 1.5 ram and save 295 00:11:47,760 --> 00:11:50,310 and now we have our two boxes and the 296 00:11:50,320 --> 00:11:52,069 margin has pushed them away from the 297 00:11:52,079 --> 00:11:54,870 edge the margin has also provided space 298 00:11:54,880 --> 00:11:56,949 between the two boxes here and now that 299 00:11:56,959 --> 00:11:59,190 we have a font size on our container we 300 00:11:59,200 --> 00:12:01,430 could go ahead and switch this back to 301 00:12:01,440 --> 00:12:03,190 ems and remember 302 00:12:03,200 --> 00:12:06,710 one m one e m would be the same as the 303 00:12:06,720 --> 00:12:08,629 font size so it would be equal to the 304 00:12:08,639 --> 00:12:12,069 1.5 rim so if we make this change we 305 00:12:12,079 --> 00:12:14,069 just change it to 1 m 306 00:12:14,079 --> 00:12:16,470 and our sizing should stay the same and 307 00:12:16,480 --> 00:12:20,230 it does if we change this to 1.5 it will 308 00:12:20,240 --> 00:12:21,750 get bigger 309 00:12:21,760 --> 00:12:23,910 yes and now we have more padding we 310 00:12:23,920 --> 00:12:25,829 could add more margin by doing the same 311 00:12:25,839 --> 00:12:27,670 if we want to so let's go ahead and do 312 00:12:27,680 --> 00:12:28,550 that 313 00:12:28,560 --> 00:12:30,310 and now let's go ahead 314 00:12:30,320 --> 00:12:32,710 and experiment with the margin and the 315 00:12:32,720 --> 00:12:34,629 padding because we don't have to have 316 00:12:34,639 --> 00:12:37,670 the same setting on the top right bottom 317 00:12:37,680 --> 00:12:40,389 and left and i did say that order 318 00:12:40,399 --> 00:12:42,389 specifically for a reason because for 319 00:12:42,399 --> 00:12:45,670 the margin we could just say margin 320 00:12:45,680 --> 00:12:49,110 top and here let's go ahead and say 1.5 321 00:12:49,120 --> 00:12:50,790 em and save 322 00:12:50,800 --> 00:12:52,389 and look what happens to our other 323 00:12:52,399 --> 00:12:54,310 margins the left and right margins are 324 00:12:54,320 --> 00:12:56,629 gone and you can't really see that we 325 00:12:56,639 --> 00:12:58,949 lost the margin on the bottom but we did 326 00:12:58,959 --> 00:13:00,470 the only thing separating these 327 00:13:00,480 --> 00:13:03,590 containers now is the margin on the top 328 00:13:03,600 --> 00:13:05,509 so now let's go ahead and add some 329 00:13:05,519 --> 00:13:07,910 margin on the right 330 00:13:07,920 --> 00:13:10,629 and here we'll set this to 2em and save 331 00:13:10,639 --> 00:13:12,629 so it's just a little bigger and now we 332 00:13:12,639 --> 00:13:15,030 do have margin on the right but still no 333 00:13:15,040 --> 00:13:16,949 margin on the bottom and no margin on 334 00:13:16,959 --> 00:13:18,790 the left i'm going to press shift alt 335 00:13:18,800 --> 00:13:20,389 and the down arrow 336 00:13:20,399 --> 00:13:22,870 and now instead of the right i'm going 337 00:13:22,880 --> 00:13:24,550 to switch this one to 338 00:13:24,560 --> 00:13:25,750 bottom 339 00:13:25,760 --> 00:13:28,150 and save and now we have some more 340 00:13:28,160 --> 00:13:29,990 margin here on the bottom so the 341 00:13:30,000 --> 00:13:32,230 separation between these two boxes got 342 00:13:32,240 --> 00:13:33,670 bigger that's the only thing you could 343 00:13:33,680 --> 00:13:35,430 really see right there 344 00:13:35,440 --> 00:13:38,150 and now on the right let's go ahead and 345 00:13:38,160 --> 00:13:40,069 switch i mean on the left let's go ahead 346 00:13:40,079 --> 00:13:42,790 and switch this to two ems as well and 347 00:13:42,800 --> 00:13:45,350 you can see we got the same thing as if 348 00:13:45,360 --> 00:13:46,710 we just said 349 00:13:46,720 --> 00:13:50,069 margin 2em except we wanted a margin on 350 00:13:50,079 --> 00:13:53,269 top of 1.5 amp so there is shorthand for 351 00:13:53,279 --> 00:13:55,590 this so i'm going to comment all four of 352 00:13:55,600 --> 00:13:58,629 these out and i'll press shift alt and 353 00:13:58,639 --> 00:14:00,629 the letter a to do that 354 00:14:00,639 --> 00:14:02,870 there you can see a css comment so it 355 00:14:02,880 --> 00:14:04,389 commented those out so right now there 356 00:14:04,399 --> 00:14:06,389 will be no margin once again now the 357 00:14:06,399 --> 00:14:09,269 boxes are next to each other no margin 358 00:14:09,279 --> 00:14:11,670 on the left and right but our shorthand 359 00:14:11,680 --> 00:14:13,750 is just saying margin and when i say 360 00:14:13,760 --> 00:14:15,829 this 1.5 361 00:14:15,839 --> 00:14:16,790 em 362 00:14:16,800 --> 00:14:19,910 that applies it to top bottom 363 00:14:19,920 --> 00:14:21,670 left and right and it actually goes in 364 00:14:21,680 --> 00:14:24,790 the order top right bottom left so now 365 00:14:24,800 --> 00:14:26,550 we could put in different settings with 366 00:14:26,560 --> 00:14:29,509 the shorthand if we wanted to so 1.5 on 367 00:14:29,519 --> 00:14:30,550 top 368 00:14:30,560 --> 00:14:31,829 and then 369 00:14:31,839 --> 00:14:36,230 2 m's on the right and the left and then 370 00:14:36,240 --> 00:14:39,350 2 m's on the bottom and i can save 371 00:14:39,360 --> 00:14:41,750 and that is the same thing as when we 372 00:14:41,760 --> 00:14:44,790 had all four of these right here now if 373 00:14:44,800 --> 00:14:46,790 i just wanted to have 374 00:14:46,800 --> 00:14:50,550 1.5 on the top and the bottom and two on 375 00:14:50,560 --> 00:14:52,470 the left and the right i could delete 376 00:14:52,480 --> 00:14:54,470 this third setting right here 377 00:14:54,480 --> 00:14:56,710 and that's what we get so now it will 378 00:14:56,720 --> 00:14:59,430 take 1.5 and apply it to the top and the 379 00:14:59,440 --> 00:15:00,629 bottom 380 00:15:00,639 --> 00:15:03,509 and 2 and apply it to the right and the 381 00:15:03,519 --> 00:15:06,629 left however you can provide all four 382 00:15:06,639 --> 00:15:09,430 settings so we could go 3 383 00:15:09,440 --> 00:15:10,949 and 4 384 00:15:10,959 --> 00:15:13,030 and then we would have the shorthand 385 00:15:13,040 --> 00:15:15,990 notice the left margin the final value 386 00:15:16,000 --> 00:15:18,470 here is much larger twice as large 387 00:15:18,480 --> 00:15:20,629 actually as the right margin and then 388 00:15:20,639 --> 00:15:21,670 the bottom 389 00:15:21,680 --> 00:15:23,509 is definitely larger than the top margin 390 00:15:23,519 --> 00:15:25,269 because here you can see only the top 391 00:15:25,279 --> 00:15:27,269 margin as it applies to the first 392 00:15:27,279 --> 00:15:29,990 container and now you can see 393 00:15:30,000 --> 00:15:31,990 the top margin and the bottom margin 394 00:15:32,000 --> 00:15:34,389 here combined to create the space 395 00:15:34,399 --> 00:15:37,509 between the two boxes now this same idea 396 00:15:37,519 --> 00:15:40,389 for shorthand also applies to padding so 397 00:15:40,399 --> 00:15:43,509 i will copy these actually cut them and 398 00:15:43,519 --> 00:15:45,670 just go back to the one setting for 399 00:15:45,680 --> 00:15:47,509 margins so that looks a little bit more 400 00:15:47,519 --> 00:15:50,470 normal again but now let's apply the 401 00:15:50,480 --> 00:15:52,310 same thing to the padding and we'll see 402 00:15:52,320 --> 00:15:55,269 how that changes so now we have a much 403 00:15:55,279 --> 00:15:57,910 larger left padding of four twice as 404 00:15:57,920 --> 00:15:59,829 much as we have on the right 405 00:15:59,839 --> 00:16:02,310 and then we have a larger bottom than we 406 00:16:02,320 --> 00:16:04,389 do on top this is easier to see because 407 00:16:04,399 --> 00:16:06,310 it's inside of our container and 408 00:16:06,320 --> 00:16:08,069 remember if you're ever having a hard 409 00:16:08,079 --> 00:16:10,069 time seeing all of this different white 410 00:16:10,079 --> 00:16:11,910 space i guess i dragged visual studio 411 00:16:11,920 --> 00:16:13,670 code i meant to grab the edge of chrome 412 00:16:13,680 --> 00:16:15,910 here i'll pull this over 413 00:16:15,920 --> 00:16:18,310 right click choose inspect 414 00:16:18,320 --> 00:16:20,710 open up the dev tools again and we can 415 00:16:20,720 --> 00:16:23,350 see all of this hidden white space much 416 00:16:23,360 --> 00:16:26,230 clearer when we look at the box model so 417 00:16:26,240 --> 00:16:28,069 once again in dev tools choosing the 418 00:16:28,079 --> 00:16:30,550 computed tab but we also need to 419 00:16:30,560 --> 00:16:32,389 highlight what we're going to look at so 420 00:16:32,399 --> 00:16:35,110 i'm going to choose this main container 421 00:16:35,120 --> 00:16:36,949 and now we can see the space as it's 422 00:16:36,959 --> 00:16:39,749 applied here so here's the content 423 00:16:39,759 --> 00:16:42,150 here's the padding and see we have 48 424 00:16:42,160 --> 00:16:44,790 pixels on the right but 96 on the left 425 00:16:44,800 --> 00:16:49,030 twice as much we have 36 on top but 72 426 00:16:49,040 --> 00:16:50,790 on the bottom which is twice as much 427 00:16:50,800 --> 00:16:53,350 also so we can definitely see that our 428 00:16:53,360 --> 00:16:55,509 padding settings over here once i drag 429 00:16:55,519 --> 00:16:58,389 this over are being applied as we 430 00:16:58,399 --> 00:17:00,790 specified them in this shorthand okay 431 00:17:00,800 --> 00:17:02,790 back to visual studio code i'm going to 432 00:17:02,800 --> 00:17:04,870 resize chrome once again so we can see 433 00:17:04,880 --> 00:17:06,470 our code better 434 00:17:06,480 --> 00:17:08,470 dragging this over 435 00:17:08,480 --> 00:17:10,230 dragging visual studio code back over 436 00:17:10,240 --> 00:17:12,789 here there we go and we can do the same 437 00:17:12,799 --> 00:17:15,270 thing you might expect with border 438 00:17:15,280 --> 00:17:17,270 actually first worth discussing you can 439 00:17:17,280 --> 00:17:19,270 just delete the two pixels 440 00:17:19,280 --> 00:17:21,350 and then when we save it actually gets a 441 00:17:21,360 --> 00:17:23,189 little thicker because the default is 442 00:17:23,199 --> 00:17:26,309 more like three pixels for the size here 443 00:17:26,319 --> 00:17:28,470 i'm going to delete this odd sizing for 444 00:17:28,480 --> 00:17:30,789 the padding that i used just to 445 00:17:30,799 --> 00:17:32,390 indicate the different 446 00:17:32,400 --> 00:17:34,549 sides for the padding and we'll go back 447 00:17:34,559 --> 00:17:36,630 to kind of a normal look here we've got 448 00:17:36,640 --> 00:17:39,110 two containers and they have equal 449 00:17:39,120 --> 00:17:41,190 padding and equal margin around them 450 00:17:41,200 --> 00:17:43,029 these settings also apply to the 451 00:17:43,039 --> 00:17:45,270 individual border sides so that means we 452 00:17:45,280 --> 00:17:48,310 can say border dash top and here we 453 00:17:48,320 --> 00:17:49,430 could say 454 00:17:49,440 --> 00:17:50,950 5 pixels 455 00:17:50,960 --> 00:17:53,110 solid and then i'll go ahead and press 456 00:17:53,120 --> 00:17:55,430 shift alt and the down arrow and then 457 00:17:55,440 --> 00:17:57,590 instead of border top i'll go ahead and 458 00:17:57,600 --> 00:17:59,190 say border 459 00:17:59,200 --> 00:18:02,230 right and i'll say 460 00:18:02,240 --> 00:18:06,870 10 pixels and here i'll say dotted 461 00:18:06,880 --> 00:18:08,390 and save 462 00:18:08,400 --> 00:18:10,549 and now we can see we had some major 463 00:18:10,559 --> 00:18:12,390 changes here and we didn't specify a 464 00:18:12,400 --> 00:18:14,470 color so these settings 465 00:18:14,480 --> 00:18:16,710 were to override what we had set with 466 00:18:16,720 --> 00:18:19,270 shorthand above and so the default color 467 00:18:19,280 --> 00:18:21,669 is black but we have a dotted right and 468 00:18:21,679 --> 00:18:23,669 we have a solid top so we could have 469 00:18:23,679 --> 00:18:25,750 specified different colors here as well 470 00:18:25,760 --> 00:18:27,270 so we could say 471 00:18:27,280 --> 00:18:29,669 green and then of course over here we 472 00:18:29,679 --> 00:18:32,310 can say something different like 473 00:18:32,320 --> 00:18:33,270 yellow 474 00:18:33,280 --> 00:18:35,430 and save and now 475 00:18:35,440 --> 00:18:37,750 that is ugly that definitely changed our 476 00:18:37,760 --> 00:18:39,350 borders though so i'll switch that to 477 00:18:39,360 --> 00:18:42,070 blue and save our eyes just a little bit 478 00:18:42,080 --> 00:18:44,230 and if we wanted to specify these 479 00:18:44,240 --> 00:18:46,470 individually we could even say border 480 00:18:46,480 --> 00:18:47,750 top 481 00:18:47,760 --> 00:18:50,310 width and then we wouldn't specify the 482 00:18:50,320 --> 00:18:52,310 solid or green here so you can break out 483 00:18:52,320 --> 00:18:53,110 each 484 00:18:53,120 --> 00:18:55,830 individual setting as well so now you 485 00:18:55,840 --> 00:18:58,070 can see we just changed the width of the 486 00:18:58,080 --> 00:19:00,870 top one likewise instead of width 487 00:19:00,880 --> 00:19:03,750 there's also border top let me switch 488 00:19:03,760 --> 00:19:06,070 that there we go style and this is where 489 00:19:06,080 --> 00:19:07,750 we're specifying 490 00:19:07,760 --> 00:19:10,390 dotted or anything else here's ridge is 491 00:19:10,400 --> 00:19:12,950 another value we'll save that and so now 492 00:19:12,960 --> 00:19:14,470 the top is a little bit different it 493 00:19:14,480 --> 00:19:16,710 looks pretty much like the solid setting 494 00:19:16,720 --> 00:19:18,950 does and then of course there would be 495 00:19:18,960 --> 00:19:20,470 border top 496 00:19:20,480 --> 00:19:21,430 color 497 00:19:21,440 --> 00:19:23,190 and we could turn this to any color we 498 00:19:23,200 --> 00:19:26,310 want so i'll choose blue here as well 499 00:19:26,320 --> 00:19:29,029 and now we have a dashed blue line 500 00:19:29,039 --> 00:19:31,669 across the top of our border so so many 501 00:19:31,679 --> 00:19:33,830 settings for the border when you break 502 00:19:33,840 --> 00:19:36,070 them out individually we had border top 503 00:19:36,080 --> 00:19:38,789 but then we also specified border top 504 00:19:38,799 --> 00:19:41,909 width border top style border top color 505 00:19:41,919 --> 00:19:43,350 and then of course you can do that 506 00:19:43,360 --> 00:19:45,190 instead of for top you can do right 507 00:19:45,200 --> 00:19:47,430 bottom and left as well 508 00:19:47,440 --> 00:19:49,430 often because of this because there are 509 00:19:49,440 --> 00:19:52,150 so many i'll delete this i just use the 510 00:19:52,160 --> 00:19:54,789 shorthand i usually want my borders to 511 00:19:54,799 --> 00:19:56,789 have the same width all the way around 512 00:19:56,799 --> 00:19:59,430 so previously i'd had two pixels here 513 00:19:59,440 --> 00:20:01,350 and then i chose dash let's choose a 514 00:20:01,360 --> 00:20:03,590 different one here let's use 515 00:20:03,600 --> 00:20:05,270 outset 516 00:20:05,280 --> 00:20:08,310 and we'll save and we can see it changed 517 00:20:08,320 --> 00:20:10,470 our frame around the box another one 518 00:20:10,480 --> 00:20:12,789 that i like is called double 519 00:20:12,799 --> 00:20:15,110 and i'll put a link to the border page 520 00:20:15,120 --> 00:20:17,669 from mdn in the description and you can 521 00:20:17,679 --> 00:20:19,510 see all of the different values there 522 00:20:19,520 --> 00:20:21,510 let's make this larger so we can really 523 00:20:21,520 --> 00:20:22,230 see 524 00:20:22,240 --> 00:20:24,549 the double what it does here i'll save 525 00:20:24,559 --> 00:20:26,149 and there you go we've got our double 526 00:20:26,159 --> 00:20:28,310 lines now around each container while 527 00:20:28,320 --> 00:20:30,470 we're covering border one other setting 528 00:20:30,480 --> 00:20:33,190 to cover is outline outline is not part 529 00:20:33,200 --> 00:20:34,950 of the box model because the difference 530 00:20:34,960 --> 00:20:36,870 between it and the border is that it 531 00:20:36,880 --> 00:20:39,590 doesn't take up space but you style 532 00:20:39,600 --> 00:20:41,990 outline much like you would the border 533 00:20:42,000 --> 00:20:45,190 so here i'm going to choose 5 pixels and 534 00:20:45,200 --> 00:20:46,870 i'll choose solid 535 00:20:46,880 --> 00:20:48,630 and then let's make the outline a 536 00:20:48,640 --> 00:20:50,870 different color entirely let's go with 537 00:20:50,880 --> 00:20:53,270 purple 538 00:20:53,280 --> 00:20:56,710 and if i save this now we can see purple 539 00:20:56,720 --> 00:20:59,750 wrapping outside of our border but again 540 00:20:59,760 --> 00:21:02,789 the outline is not calculated because it 541 00:21:02,799 --> 00:21:04,390 doesn't take up space so it's not 542 00:21:04,400 --> 00:21:07,029 calculated into that box model equation 543 00:21:07,039 --> 00:21:09,510 another property that the outline has 544 00:21:09,520 --> 00:21:11,350 that is very handy 545 00:21:11,360 --> 00:21:14,390 is outline dash offset so instead of 546 00:21:14,400 --> 00:21:16,549 being right up against our box we can 547 00:21:16,559 --> 00:21:19,909 say we want the offset to be 5 pixels 548 00:21:19,919 --> 00:21:22,870 and save and see how we pushed it now 5 549 00:21:22,880 --> 00:21:26,149 pixels further out from our border so 550 00:21:26,159 --> 00:21:29,029 it's offset 5 pixels from the rest of 551 00:21:29,039 --> 00:21:31,350 our box and something worth considering 552 00:21:31,360 --> 00:21:34,070 sometimes is using a negative value so 553 00:21:34,080 --> 00:21:36,630 if i put in negative 10 pixels 554 00:21:36,640 --> 00:21:39,669 we'll now see the outside the outline 555 00:21:39,679 --> 00:21:43,029 is inside of our box here and so let's 556 00:21:43,039 --> 00:21:44,549 go ahead and change this some more so we 557 00:21:44,559 --> 00:21:46,390 get it a little further inside maybe 558 00:21:46,400 --> 00:21:49,430 even 20 pixels and save and we can 559 00:21:49,440 --> 00:21:52,390 clearly see the outline is now inside of 560 00:21:52,400 --> 00:21:54,710 our box model okay in the beginning i 561 00:21:54,720 --> 00:21:57,430 promised to show how to turn a box into 562 00:21:57,440 --> 00:21:59,350 a circle before we were finished so 563 00:21:59,360 --> 00:22:01,110 let's do that i need to go back to the 564 00:22:01,120 --> 00:22:02,230 file tree 565 00:22:02,240 --> 00:22:05,190 and find our index html and hide the 566 00:22:05,200 --> 00:22:07,110 file tree with ctrl b 567 00:22:07,120 --> 00:22:09,590 and i just want to put a div down here 568 00:22:09,600 --> 00:22:11,590 i'm going to keep it in the side of the 569 00:22:11,600 --> 00:22:14,149 main element so i'll just type 570 00:22:14,159 --> 00:22:17,110 div and then i want to give this div 571 00:22:17,120 --> 00:22:20,710 a class and set this equal 572 00:22:20,720 --> 00:22:21,590 to 573 00:22:21,600 --> 00:22:23,430 there we go to circle 574 00:22:23,440 --> 00:22:25,270 i still didn't spell circle right i'm 575 00:22:25,280 --> 00:22:27,430 having a rough time today save there 576 00:22:27,440 --> 00:22:29,750 we've got a div with the class of circle 577 00:22:29,760 --> 00:22:32,950 okay we can close the html and now let's 578 00:22:32,960 --> 00:22:35,190 style our circle class 579 00:22:35,200 --> 00:22:37,669 so we'll start with circle definition 580 00:22:37,679 --> 00:22:39,430 here for the class 581 00:22:39,440 --> 00:22:41,990 and let's give the circle a background 582 00:22:42,000 --> 00:22:45,270 color 583 00:22:45,280 --> 00:22:47,830 of gold but we haven't given it any size 584 00:22:47,840 --> 00:22:50,630 yet so let's say a width 585 00:22:50,640 --> 00:22:53,110 of 100 pixels 586 00:22:53,120 --> 00:22:56,470 and a height of 100 pixels 587 00:22:56,480 --> 00:22:57,909 and that doesn't look like much of a 588 00:22:57,919 --> 00:22:59,909 circle yet but it will let's go ahead 589 00:22:59,919 --> 00:23:02,549 and add a border now of two pixels 590 00:23:02,559 --> 00:23:05,510 we'll make this solid black 591 00:23:05,520 --> 00:23:07,590 and now we see our border applied to our 592 00:23:07,600 --> 00:23:08,710 square 593 00:23:08,720 --> 00:23:11,190 and let's add an outline as well well we 594 00:23:11,200 --> 00:23:14,470 need a new line for that outline 595 00:23:14,480 --> 00:23:16,950 now the outline can be 2 pixels let's 596 00:23:16,960 --> 00:23:19,669 say solid and let's go with red for now 597 00:23:19,679 --> 00:23:21,350 so it'll match everything else a little 598 00:23:21,360 --> 00:23:23,909 bit and stand out now let's give it an 599 00:23:23,919 --> 00:23:26,230 offset also 600 00:23:26,240 --> 00:23:29,350 and we'll make this 0.25 round 601 00:23:29,360 --> 00:23:31,590 and save so yeah we've got just a little 602 00:23:31,600 --> 00:23:33,270 space there now let's create some 603 00:23:33,280 --> 00:23:35,990 separation from the other content and so 604 00:23:36,000 --> 00:23:37,669 i'll just leave this at the top but i'll 605 00:23:37,679 --> 00:23:39,430 make the margin 606 00:23:39,440 --> 00:23:40,789 three rim 607 00:23:40,799 --> 00:23:44,070 and save and now it's pushed itself away 608 00:23:44,080 --> 00:23:45,750 but something we didn't cover with the 609 00:23:45,760 --> 00:23:47,830 margin if you set the margin this 610 00:23:47,840 --> 00:23:49,590 doesn't work for top and bottom but if 611 00:23:49,600 --> 00:23:51,190 you set it for 612 00:23:51,200 --> 00:23:53,350 left and right notice we've got three 613 00:23:53,360 --> 00:23:55,590 ram for top and bottom now we can use 614 00:23:55,600 --> 00:23:58,870 the keyword auto for left and right 615 00:23:58,880 --> 00:24:01,830 and this will center it horizontally 616 00:24:01,840 --> 00:24:04,230 that means in the middle left and right 617 00:24:04,240 --> 00:24:07,190 so now we put what will be a circle our 618 00:24:07,200 --> 00:24:09,350 gold square inside 619 00:24:09,360 --> 00:24:11,830 of our main element and it's at the 620 00:24:11,840 --> 00:24:14,230 center horizontally not vertically but 621 00:24:14,240 --> 00:24:16,390 at least it is horizontally and now to 622 00:24:16,400 --> 00:24:18,710 calculate our circle we essentially just 623 00:24:18,720 --> 00:24:21,669 need to set one other border property 624 00:24:21,679 --> 00:24:24,870 and we set it to half the value of the 625 00:24:24,880 --> 00:24:27,430 width and the height so this border 626 00:24:27,440 --> 00:24:29,269 property is called border radius i'll 627 00:24:29,279 --> 00:24:32,789 put it right under border 628 00:24:32,799 --> 00:24:35,110 and we'll set it first just so you can 629 00:24:35,120 --> 00:24:36,789 see how it works let's set it to 20 630 00:24:36,799 --> 00:24:39,029 pixels and you'll see what border radius 631 00:24:39,039 --> 00:24:42,230 does look how it rounded the corners 632 00:24:42,240 --> 00:24:45,190 of our square so now we have more like a 633 00:24:45,200 --> 00:24:47,029 cool button kind of like you would see 634 00:24:47,039 --> 00:24:49,029 there and we can continue to round that 635 00:24:49,039 --> 00:24:53,029 but if we set it to 50 pixels which is 636 00:24:53,039 --> 00:24:55,909 half of the width and half of the height 637 00:24:55,919 --> 00:24:57,350 and save 638 00:24:57,360 --> 00:24:59,190 we've now got a circle now there's 639 00:24:59,200 --> 00:25:01,029 always more than one way to do things in 640 00:25:01,039 --> 00:25:03,269 css and typically in programming in 641 00:25:03,279 --> 00:25:05,110 general so if you've got other ways you 642 00:25:05,120 --> 00:25:07,909 like to make circles in css go ahead and 643 00:25:07,919 --> 00:25:09,909 leave those in the comments below but i 644 00:25:09,919 --> 00:25:11,750 hope this has helped you learn about the 645 00:25:11,760 --> 00:25:14,070 box model today so we have the content 646 00:25:14,080 --> 00:25:16,870 on the inside then we have the padding 647 00:25:16,880 --> 00:25:18,870 then we have the border and finally on 648 00:25:18,880 --> 00:25:21,350 the outside we have the margin and when 649 00:25:21,360 --> 00:25:24,710 we apply our basic css reset and we set 650 00:25:24,720 --> 00:25:27,909 the box siding to border box the box 651 00:25:27,919 --> 00:25:30,070 sizing to border box 652 00:25:30,080 --> 00:25:32,310 then the calculation includes the 653 00:25:32,320 --> 00:25:35,269 content the padding and the border 654 00:25:35,279 --> 00:25:37,590 instead of just the content remember to 655 00:25:37,600 --> 00:25:39,350 keep striving for progress over 656 00:25:39,360 --> 00:25:41,669 perfection and a little progress every 657 00:25:41,679 --> 00:25:44,149 day will go a very long way 658 00:25:44,159 --> 00:25:45,750 please give this video a like if it's 659 00:25:45,760 --> 00:25:47,909 helped you and thank you for watching 660 00:25:47,919 --> 00:25:49,590 and subscribing you're helping my 661 00:25:49,600 --> 00:25:50,789 channel grow 662 00:25:50,799 --> 00:25:52,870 have a great day and let's write more 663 00:25:52,880 --> 00:25:56,919 code together very soon 46036

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