Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

padding increases width and height of div

Tags:

html

css

how can I modify these divs so that when I change their padding, their height and width do not expand? I have tried to implement

.outer, .inner {
    display: block;
}

.outer {
    /* specify fixed width */
    width: 300px;
    padding: 0;
}

.inner {
    /* specify padding, can be changed while remaining fixed width of .outer */
    padding: 5px;
}

from here

by giving the parent divs fixed_width and relative_container width:700px;height:100px; padding:0px;, but when I apply padding to .content or .obscure, the divs expand to cover .extra_margins below. Thanks!

http://jsfiddle.net/loren_hibbard/ZmJ9R/

like image 457
1252748 Avatar asked Jan 16 '23 02:01

1252748


1 Answers

You can use CSS3 box-sizing property to do this:

box-sizing: border-box;

http://css-tricks.com/box-sizing/

Supported in IE8+ but some browsers may require a prefix:

http://caniuse.com/css3-boxsizing

like image 153
Kevin Boucher Avatar answered Jan 17 '23 16:01

Kevin Boucher