Skip to content

Instantly share code, notes, and snippets.

@amrvitale
Created November 3, 2019 20:59
Show Gist options
  • Save amrvitale/16666e043821ac349981a38f2188cf77 to your computer and use it in GitHub Desktop.
Save amrvitale/16666e043821ac349981a38f2188cf77 to your computer and use it in GitHub Desktop.
How much space does the element take up?
//How much space does this element take up, assuming we use the default setting for box-sixing?
//Default setting for box-sizing is content-box (per W3).
div {
border: 6px solid #949599;
height: 100px;
margin: 20px;
padding: 20px;
width: 400px;
}
//TOTAL width = width + (2 X padding) + (2 X margin) + (2 X border)
//TOTAL width = 400px + (2 X 20px) + (2 X 20px) + (2 X 6px)
//TOTAL width = 492px
//TOTAL height = height + (2 X padding) + (2 X margin) + (2 X border)
//TOTAL height = 100px + (2 X 20px) + (2 X 20px) + (2 X 6px)
//TOTAL height = 292px
//https://dev.to/neshaz/how-to-treat-your-css-elements-the-box-sizing-property-13p3 //use for conceptual help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment