Skip to content

Instantly share code, notes, and snippets.

@radiovisual
Created November 9, 2014 22:42
Show Gist options
  • Save radiovisual/0607b4a1150e2edb8c99 to your computer and use it in GitHub Desktop.
Save radiovisual/0607b4a1150e2edb8c99 to your computer and use it in GitHub Desktop.
box-sizing recommendation to help fix the annoying box model issues in html/css
/*Ugh. If I say the width is 200px, gosh darn it, it’s gonna be a 200px wide box even if I have 20px of padding.
So as you know, this is NOT how the box model has worked for the past ten years. Anyway, I have a recommendation
for your CSS going forward: (Paul Irish via: http://www.paulirish.com/2012/box-sizing-border-box-ftw/) */
/* apply a natural box layout model to all elements, but allowing components to change */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment