Kill the old-style CSS box model with 'box-sizing: border-box '
* {-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;}
This small piece of code re-works the default CSS box model by forcing the web browser to use any extra border and padding attributes and include them in the set-width of an object rather than add it.
For example, a 200px box with 10px padding and a 5px border would still be viewed as 200px wide and NOT the standard width of 230px (200 + 10 + 10 + 5 + 5).
It's pretty awesome but remember, it doesn't work for margins (shame).
Written by Kimb Jones
Related protips
1 Response
Margins if made to work to be calculated inside the box, then it should already be called a "padding" too. Its more appropriate now that the box-sizing puts the padding inside, and the margin remains outside.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#