...

View Full Version : padding percent



croatiankid
05-13-2007, 05:12 PM
Adding a padding to an element in %. Is that % of the element's dimension (height or width)? So width:99% and padding-left:1% would make it 100% the width of its parent element?

koyama
05-13-2007, 06:39 PM
Adding a padding to an element in %. Is that % of the element's dimension (height or width)? So width:99% and padding-left:1% would make it 100% the width of its parent element?
The answer to this should be clear from CSS 2.1 Working Draft, section 8.4 (http://www.w3.org/TR/CSS21/box.html#padding-properties).

Percentage values of the properties padding-top, padding-right, padding-bottom, padding-left are all calculated with respect to the width of the containing block.

This is consistent as long as the width of the containing block does not depend on the width of its children. Examples of these are shrink-to-fit elements such as auto-width floats, auto-width absolutely positioned elements, etc. Therefore, in such cases, the specification, explicitly, does not define what the computed value should be.

Margins are treated similarly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum