Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: padding percent

  1. #1
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts

    padding percent

    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?

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by croatiankid View Post
    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.

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •