(window.webpackJsonp=window.webpackJsonp||[]).push([[25],{421:function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiAAAAEsCAYAAAD6owj6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABxjSURBVHgB7d3LjxzV+Tfw4zcgC0uOibwADCj2xgtiCSKywNlwWQQWSIAEZAkEUJbc9rH9B4BhDeGyDCABEgvYcFtgFlixFRNLlhCOfFtZwgwyMRu/fuqnM2nG5fGUXfV45sznI7Wmq7u6uhmmz3l8zrdOrTl7TgEASPT/CgBAMgUIAJBOAQIApFOAAADpFCAAQDoFCACQTgECAKRTgAAA6RQgAEA6BQgAkE4BAgCkU4AAAOkUIABAOgUIAJBOAQIApFOAAADpFCAAQDoFCACQTgECAKRTgAAA6RQgAEA6BQgAkE4BAgCkU4AAAOl+tfOcMrG9e/eWTZs2zd8/ceLEkrZ//vnnsm/fvnLy5Mly3XXXTb49NzdXDhw4UH788ceycePGybfjfQ8ePNh9jmuvvXby7ePHj5dDhw51v+f169dPvn348OHy7bfflrVr15Z169albcd7x2PxWeKxqbfj/+VVV13V/b89cuTI5NuX8l261O2s717dzvru1e2s717dzvru1e3s717dzvru1e2s717dvpTvUr3P/6w5e04BAEhkCgYASJdSgMTwEwCsRvrAflcVABjJm2++OX//wQcf7DIwsyK78dlnn81vP/7442Vq77//fnnllVe6z/PMM88UlgcZEABGs2bNmvn7L7/88nkdfhQoTzzxxPx2Rhf00EMPdUXIXXfdVT799NPC8qAAAWA0swVIX4d/9913/2IEJKMLilGXt956qzzwwAPltttuKywPKVMwMf91++23FwBWjyg0vv/++/lpmDr9EtvxeN/+H3zwQfdcFApRMGzevHn+uc8//7zceuut3eujoNixY0f3fBw3pljidVH0/Pa3v+32vfPOO7vtOMW7vn8cd+Gx4j1DPPfYY4+VsekDL+Bsgn/9619nAWhfdCtxe/zxx7uf56Zh5p974403usfOFQXz+1XPPvvs/GP1dq64OP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ImUKZmymYAAYy9RTMPRLmYKJ+S8AWI30gf1kQABgQvrAftYBAYAJ6QP7WQcEACakD+wnAwIAE9IH9pMBAYAJ6QP7yYAAwIT0gf1kQABgQvrAfjIgADAhfWA/GRAAmJA+sF9KAZKxlj8ALEf6wH4pBcj69esLAKxG+sB+KQVIXN0QAFYjfWC/lAJkbm6uAMBqpA/sJwMCABPSB/aTAQGACekD+8mAAMCE9IH9ZEAAYEL6wH4yIAAwIX1gPxkQAJiQPrCfDAgATEgf2E8GBAAmpA/sJwMCABPSB/aTAQGACekD+605e06ZWMx/jVkBrlmzpgDAVMbsGsfuA1shAwIAE9IH9ksZATlz5kxZu3ZtGYsREACmNGbXOHYf2IqUAmRsChAAprQCu8YVJ2UK5sCBAwUAViN9YL+rSoIYfhqTyhSAlWLsPrAVKzIDAgArhT6w34rMgAAAK5sMCABMSB/YL6UAMf8FwGqlD+wnAwIAE9IH9pMBAQDSyYAAwIT0gf1kQABgQvrAfjIgADAhfWA/GRAAIJ0MCABMSB/YTwYEACakD+xnCgYASJcyAgIAMCulANm7d28BgNVIH9jPCAgAkE4GBABIZwQEAEj3q53nlInF/NemTZvm7584cWJJ2z///HPZt29fOXnyZLnuuusm356bm+vO1/7xxx/Lxo0bJ9+O9z148GD3Oa699trJt48fP14OHTrU/Z7Xr18/+fbhw4fLt99+260AuG7durTteO94LD5LPDb1dvy/vOqqq7r/t0eOHJl8+1K+S5e6nfXdq9tZ3726nfXdq9tZ3726nf3dq9tZ3726nfXdq9uX8l2q9/kfUzAAQDpTMABAOgUIAJBOAQIApFOAAADpFCAAQDoFCACQTgECAKRTgAAA6RQgAEA6BQgAkE4BAgCkU4AAAOkUIABAOgUIAJBOAQIApFOAAADpFCAAQDoFCACQTgECAKRTgAAA6RQgAEA6BQgAkE4BAgCkU4AAAOn+P214gQ4TE6coAAAAAElFTkSuQmCC"},422:function(e,t,a){e.exports=a.p+"assets/img/box-example.7a24d3e6.png"},572:function(e,t,a){"use strict";a.r(t);var s=a(56),o=Object(s.a)({},(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"the-css-box-model"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#the-css-box-model"}},[e._v("#")]),e._v(" The CSS Box Model")]),e._v(" "),s("p",[e._v("In this lecture we'll be talking about a "),s("em",[e._v("very")]),e._v(" important concept in CSS: the "),s("em",[e._v("box model")]),e._v(".")]),e._v(" "),s("h2",{attrs:{id:"what-is-the-box-model"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#what-is-the-box-model"}},[e._v("#")]),e._v(" What is the box model?")]),e._v(" "),s("p",[e._v("The box model is essentially how CSS determines the overall size and shape of an element on the page.")]),e._v(" "),s("p",[e._v('The box model is made up of four components: the content area, the box padding, the box borders, and the box margins. These combine together to create the "box" for a given element.')]),e._v(" "),s("p",[e._v("There are actually "),s("em",[e._v("two")]),e._v(" box models in CSS — the "),s("em",[e._v("standard")]),e._v(" box model, and the "),s("em",[e._v("alternative")]),e._v(" box model — which combine these components in different ways.")]),e._v(" "),s("p",[e._v("Let's start by looking at the standard box model.")]),e._v(" "),s("h3",{attrs:{id:"the-standard-box-model"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#the-standard-box-model"}},[e._v("#")]),e._v(" The standard box model")]),e._v(" "),s("p",[e._v("When working with the standard box model, the "),s("code",[e._v("height")]),e._v(" and "),s("code",[e._v("width")]),e._v(" properties for a given element change the size of the content area.")]),e._v(" "),s("p",[e._v("What exactly does this mean?")]),e._v(" "),s("p",[e._v("Let's look at this diagram of the CSS box model below:")]),e._v(" "),s("p",[s("img",{attrs:{src:a(421),alt:"The CSS box model."}})]),e._v(" "),s("p",[e._v("As we can see, the content area doesn't include the padding for the element, or the borders, or the margins. This is really important to understand, because it means that if you want something to take up "),s("code",[e._v("300px")]),e._v(" of horizontal space, it's not enough to just set the "),s("code",[e._v("width")]),e._v(" to "),s("code",[e._v("300px")]),e._v(".")]),e._v(" "),s("p",[e._v("Instead, we have to set the "),s("code",[e._v("width")]),e._v(" to "),s("code",[e._v("300px")]),e._v(" minus the left and right border width, minus the total horizontal padding.")]),e._v(" "),s("p",[e._v("Let's say our element has a "),s("code",[e._v("1px")]),e._v(" border on all sides, "),s("code",[e._v("10px")]),e._v(" of left padding and "),s("code",[e._v("20px")]),e._v(" of right padding. The code for that might look like this:")]),e._v(" "),s("div",{staticClass:"language-css extra-class"},[s("pre",{pre:!0,attrs:{class:"language-css"}},[s("code",[s("span",{pre:!0,attrs:{class:"token selector"}},[e._v(".box-example")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("padding-left")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 10px"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("padding-right")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 20px"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("border")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 1px solid #000"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n")])])]),s("p",[e._v("If we want out element to be "),s("code",[e._v("300px")]),e._v(" wide, what should the "),s("code",[e._v("width")]),e._v(" be set to?")]),e._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("300px - (2 x 1px) - 10px - 20px\n")])])]),s("p",[e._v("The total comes out to "),s("code",[e._v("268px")]),e._v(".")]),e._v(" "),s("div",{staticClass:"language-css extra-class"},[s("pre",{pre:!0,attrs:{class:"language-css"}},[s("code",[s("span",{pre:!0,attrs:{class:"token selector"}},[e._v(".box-example")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("width")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 268px"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("padding-left")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 10px"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("padding-right")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 20px"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("border")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" 1px solid #000"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n")])])]),s("p",[e._v("We can go into our developer tools and make sure this all worked correctly. If we hover over the element with the "),s("code",[e._v("box-example")]),e._v(" class, we should see a little box pop up which looks like this:")]),e._v(" "),s("p",[s("img",{attrs:{src:a(422),alt:"The CSS box model."}})]),e._v(" "),s("p",[e._v("The element has "),s("code",[e._v("300px")]),e._v(" of width, as expected, and "),s("code",[e._v("2px")]),e._v(" of height, due to the top and bottom border.")]),e._v(" "),s("p",[e._v("The margins are not included in this size calculation, so if you set the "),s("code",[e._v("margin")]),e._v(" property to, say, "),s("code",[e._v("10px")]),e._v(", the developer tools will still show you the same measurements.")]),e._v(" "),s("h3",{attrs:{id:"the-alternative-box-model"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#the-alternative-box-model"}},[e._v("#")]),e._v(" The alternative box model")]),e._v(" "),s("p",[e._v("All of these calculations are really fiddly, and to remedy this, an alternative to the standard box model was introduced.")]),e._v(" "),s("p",[e._v("In the alternative box model, the "),s("code",[e._v("height")]),e._v(" and "),s("code",[e._v("width")]),e._v(" properties determine the dimensions of the box to the outside of the border. This means the value we set for the "),s("code",[e._v("width")]),e._v(" and "),s("code",[e._v("height")]),e._v(" determine the overall width and height of an element, barring the margins.")]),e._v(" "),s("p",[e._v("We can tell CSS to use the alternative box model for a given element by setting the "),s("code",[e._v("box-sizing")]),e._v(" property for that element, giving it a value of "),s("code",[e._v("border-box")]),e._v(".")]),e._v(" "),s("p",[e._v("I recommend you use "),s("code",[e._v("border-box")]),e._v(" sizing for "),s("em",[e._v("all")]),e._v(" of your elements, but unfortunately it's not an inherited property, so we need to be a little clever about how we do this. We don't want to have to manually specify "),s("code",[e._v("box-sizing")]),e._v(" for every single element on the page, after all!")]),e._v(" "),s("p",[e._v("What we can do instead, is this:")]),e._v(" "),s("div",{staticClass:"language-css extra-class"},[s("pre",{pre:!0,attrs:{class:"language-css"}},[s("code",[s("span",{pre:!0,attrs:{class:"token selector"}},[e._v("*,\n*::before,\n*::after")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("box-sizing")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" inherit"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n\n"),s("span",{pre:!0,attrs:{class:"token selector"}},[e._v("body")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("box-sizing")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" border-box"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n")])])]),s("p",[e._v("Here we're using the universal selector to set the "),s("code",[e._v("box-sizing")]),e._v(" property for every element to "),s("code",[e._v("inherit")]),e._v(". We can then set the "),s("code",[e._v("box-sizing")]),e._v(" property for the "),s("code",[e._v("")]),e._v(" element. "),s("code",[e._v("")]),e._v(" is the parent of all of the visual elements on the page, which means the "),s("code",[e._v("boder-box")]),e._v(" value can be inherited throughout the entire document.")]),e._v(" "),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[e._v("Why use inherit?")]),e._v(" "),s("p",[e._v("Some of you may be wondering, why not just do something like this:")]),e._v(" "),s("div",{staticClass:"language-css extra-class"},[s("pre",{pre:!0,attrs:{class:"language-css"}},[s("code",[s("span",{pre:!0,attrs:{class:"token selector"}},[e._v("*,\n*::before,\n*::after")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("{")]),e._v("\n "),s("span",{pre:!0,attrs:{class:"token property"}},[e._v("box-sizing")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" border-box"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("}")]),e._v("\n")])])]),s("p",[e._v("There are two main reasons.")]),e._v(" "),s("ol",[s("li",[s("p",[e._v("Setting an explicit "),s("code",[e._v("box-sizing")]),e._v(" value means we can't use inheritance later on in cases where we want to switch back to the standard box model.")])]),e._v(" "),s("li",[s("p",[e._v("Using "),s("code",[e._v("*")]),e._v(" to set "),s("code",[e._v("box-sizing")]),e._v(" to "),s("code",[e._v("border-box")]),e._v(" universally has a wider reaching effect than inheriting from the "),s("code",[e._v("")]),e._v(" element. For example, the "),s("code",[e._v("")]),e._v(" element and everything in the "),s("code",[e._v("")]),e._v(" would have their "),s("code",[e._v("box-sizing")]),e._v(" set.")])])])]),e._v(" "),s("h2",{attrs:{id:"block-vs-inline-boxes"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#block-vs-inline-boxes"}},[e._v("#")]),e._v(" Block vs inline boxes")]),e._v(" "),s("p",[e._v("The picture we've been painting so far isn't entirely complete, as we've only really discussed the box model for elements being displayed as "),s("em",[e._v("blocks")]),e._v(". For inline elements, the story is a little different.")]),e._v(" "),s("p",[e._v("For example, when working with an inline element, we can't set an explicit height and width. The size of the content determines the size of the content box. Any "),s("code",[e._v("height")]),e._v(" and "),s("code",[e._v("width")]),e._v(" properties will be ignored.")]),e._v(" "),s("p",[e._v("We also can't create space above and below an element by applying vertical padding and margins. Only horizontal padding and margins will move the content around the element. The same is true of borders.")]),e._v(" "),s("p",[e._v("While vertical padding has no effect on the layout of an inline element in relation to those around it, the padding value is still being applied. This is important to note, as vertical padding will change the position of borders around an inline element. The background will also stretch to fill the space specified by the vertical padding.")]),e._v(" "),s("h2",{attrs:{id:"beyond-sizing"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#beyond-sizing"}},[e._v("#")]),e._v(" Beyond sizing")]),e._v(" "),s("p",[e._v("It's worth spending the time to get familiar with the components of the box model, even if you plan to always set the "),s("code",[e._v("box-sizing")]),e._v(" to "),s("code",[e._v("border-box")]),e._v(", as these components are used to determine the effect of other properties.")]),e._v(" "),s("p",[e._v("For example, the "),s("code",[e._v("background-origin")]),e._v(" property allows us to determine where the background ends. We can set values like "),s("code",[e._v("border-box")]),e._v(", "),s("code",[e._v("padding-box")]),e._v(", and "),s("code",[e._v("content-box")]),e._v(", which directly map onto the components of the box model we saw before.")]),e._v(" "),s("p",[e._v("You can find more information on the "),s("code",[e._v("background-origin")]),e._v(" property "),s("a",{attrs:{href:"https://developer.mozilla.org/en-US/docs/Web/CSS/background-origin",target:"_blank",rel:"noopener noreferrer"}},[e._v("here"),s("OutboundLink")],1),e._v(".")])])}),[],!1,null,null,null);t.default=o.exports}}]);