CSS DIV width is 100%

I have a DIV whose width is 512 pixels. Then inside the DIV there is another DIV. I set the THAT DIV width to 100%. However, this is happening, which I did not want.

I am trying to make it stay inside the div. As in the 5px add-on from all sides.

http://jsfiddle.net/weka/USvTC/

+3
source share
2 answers

This problem occurs because padding, and borderare not part of width: 100%.

Assuming you want to absolutely position #exp_wrap, use this: http://jsfiddle.net/thirtydot/USvTC/1/

I deleted width: 100%on .bar_wrap/ #exp_wrapand added right:5px;to #exp_wrap.

, div , width: auto, . , width: 100%, , padding border width: auto.

#exp_wrap , : http://jsfiddle.net/thirtydot/USvTC/2/

width: 100% .bar_wrap/#exp_wrap position:absolute; top:5px; left:5px; margin: 5px;. overflow: hidden .container, .

+4

512- (2 * 5) (502), 100%.

+1

All Articles