pull box sizing

Master Pull Box Sizing: Understand CSS Updates

By Melissa Davis
AD
Mastering Pull Box Sizing: A CSS Tutorial

In web design, understanding CSS box sizing is fundamental. The 'box-sizing' property determines how the total width and height of an element is calculated. The default value, 'content-box', includes only the content area of an element, ignoring padding and border. This can lead to unexpected layouts. 'Border-box', however, includes padding and border in the element's total dimensions, enhancing predictability.

Switching from 'content-box' to 'border-box' can significantly simplify your CSS. It's akin to changing wardrobe dimensions from 'runway measurements' (content-only) to 'actual garment size' (border-inclusive).

Understanding Pull Box Sizing

Introduced in CSS2.1, 'box-sizing' allows us to alter the box model. It's compatible with all major browsers and supports IE8 and above.

AD
Avoid These Mistakes When Integrating Hardware with Shaker Cabinets
Avoid These Mistakes When Integrating Hardware with Shaker Cabinets
an open cardboard box is shown with the bottom and side cut out to make it look like
an open cardboard box is shown with the bottom and side cut out to make it look like
a white box sitting on top of a table
a white box sitting on top of a table

There are two widely-used value options: 'content-box' and 'border-box'. Most browsers have 'border-box' enabled by default, making 'content-box' the legacy fallback.

The 'Content-Box' Model

'Content-Box' considers only the box's content, excluding padding, border, and margin. This makes the total width equal to the width of the content element, plus the padding on both sides.

a paper box with measurements for the top and bottom
a paper box with measurements for the top and bottom
Caixa de lata simples com furo de fita e molde de tampa cortada | Vetor Premium
Caixa de lata simples com furo de fita e molde de tampa cortada | Vetor Premium
the check box is shown with two arrows pointing towards each other and one arrow pointing to the
the check box is shown with two arrows pointing towards each other and one arrow pointing to the

In the context of 'content-box', set a box's height to 100px, add 10px of top/bottom padding, and include a 5px top/bottom border. The total vertical height becomes 120px. Similarly, the width expands with added right/left padding and border.

The 'Border-Box' Model

'Border-Box', converse to 'content-box', includes padding and border in the element's total dimensions. For a 100px high box with 10px of padding and 5px of border, 'border-box' totals 120px for the height.

AD

This simplifies layouts, as adding padding or border doesn't change the overall box size. Consequently, calculating element sizes becomes more predictable, making 'border-box' the preferred modern option.

three boxes are stacked on top of each other and labeled with the word die cut templates
three boxes are stacked on top of each other and labeled with the word die cut templates
Download box design packaging tamplate for free
Download box design packaging tamplate for free
the box is cut out and ready to be printed
the box is cut out and ready to be printed
Rebecca Janis on Instagram: "Detailed step by step 👇🏻 • Cut the sides of the drawer box to size. Make them the same size or 1/2” longer than your drawer slides. Height depends on how many drawer boxes you will have. • Attach the sides of the box to the slides using a spacer. I use a 3/4” piece of scrap so I can pull out the slide and screw it into the wood. • Measure between the two side pieces to get the measurements for the front and back piece. • Cut the front and back piece to size. I like to use 3/4” birch plywood. • Use pocket holes and wood glue to attach the front and back. The front with the pocket holes should be facing towards you and the back ugh the pocket holes should be facing towards the back. That way when you go to install the drawer front the pocket holes will be h Desain Pantry, Diy Drawers, Closet Remodel, Carpentry Diy, Escritorio De Madera, Diy Closet, Proyectos De Carpintería Fáciles, Diy Kitchen Cabinets, Diy Cabinets
Rebecca Janis on Instagram: "Detailed step by step 👇🏻 • Cut the sides of the drawer box to size. Make them the same size or 1/2” longer than your drawer slides. Height depends on how many drawer boxes you will have. • Attach the sides of the box to the slides using a spacer. I use a 3/4” piece of scrap so I can pull out the slide and screw it into the wood. • Measure between the two side pieces to get the measurements for the front and back piece. • Cut the front and back piece to size. I like to use 3/4” birch plywood. • Use pocket holes and wood glue to attach the front and back. The front with the pocket holes should be facing towards you and the back ugh the pocket holes should be facing towards the back. That way when you go to install the drawer front the pocket holes will be h Desain Pantry, Diy Drawers, Closet Remodel, Carpentry Diy, Escritorio De Madera, Diy Closet, Proyectos De Carpintería Fáciles, Diy Kitchen Cabinets, Diy Cabinets
Cabinet Drawer Pull Size
Cabinet Drawer Pull Size
an image of a box that is in the shape of a rectangle with lines on it
an image of a box that is in the shape of a rectangle with lines on it

Implementing 'Border-Box' in Your Project

Transitioning to 'border-box' involves a single line of CSS in your stylesheet: '* { box-sizing: border-box; }'. For broader application, consider including this rule in your global or base styles.

Remember, this rule applies to all elements. If you want any exceptions, apply 'content-box' to those elements. Be aware that this shifts behavior from 'content-box', requiring careful adjustment.

AD

Browser Compatibility

'Box-sizing' is well-supported across modern browsers, with IE8+ recognizing the second version of the specification. The primary concern is with older versions of IE, which may not recognize 'box-sizing' at all or interpret it differently.

an orange and black box label with the words boye brand on it's sides
an orange and black box label with the words boye brand on it's sides
the cabinet hardware size guide is shown in this screenshote screen shot from an iphone
the cabinet hardware size guide is shown in this screenshote screen shot from an iphone

For universal application, consider using tools like Modernizr to provide feature-detection and avoid performance hits from feature-tests. However, for simple projects, a simple JavaScript or CSS reset might prove sufficient.

Practical Implementation

In a real-world scenario, say you're designing a mobile application. Transitioning to 'border-box' can simplify your CSS, enhancing consistency and wrangling those pesky cross-browser inconsistencies.

AD

'Pull box sizing' is a fundamental concept in CSS, helping to standardize layouts and content distribution. Familiarize yourself with it and leverage this powerful tool to streamline your workflow and enhance your designs.

AD