From the course: CSS Essential Training
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Box-sizing and the box model fix
From the course: CSS Essential Training
Box-sizing and the box model fix
- [Instructor] Using different box model properties affects the overall size of the element. The box sizing property is used to determine how an element's total width and height are calculated. There are two values, content box, which is the default value, and border box. When box sizing is set to content box, the width and height values are applied to the content box only. Adding padding and border increases the elements total size because their dimensions are added on top of the width and height values. Margin adds space around the element, so it doesn't increase the size of the element. With the border box value, the width and height is still applied to the content box. However, when padding and border styles are added, the content box shrinks to maintain the original size that was set with the width and height properties. But just like content box, margin is not included in the sizing of the element itself, it just…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Introduction to the CSS box model1m 4s
-
(Locked)
Width, height, and display3m 7s
-
(Locked)
Padding, margin, and border4m 59s
-
(Locked)
Center-aligning with margin3m 7s
-
(Locked)
Box-sizing and the box model fix3m 31s
-
(Locked)
Working with developer tools5m 1s
-
(Locked)
Margin collapse and inline spacing2m 48s
-
(Locked)
Creating full-height layouts3m 2s
-
(Locked)
Project: List reset and header updates4m 51s
-
(Locked)
Project: Centering content with margin5m 49s
-
(Locked)
Project: Heading resets and border styles4m 4s
-
(Locked)
-
-
-
-
-
-