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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2009
    Posts
    170
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Box model: lost parent element scrollbar

    The first sample shows scrollbars correctly:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <style type="text/css">
    #parent {width:102px; height:101px; background:red; overflow:auto;}
    #child {width:100px; height:100px; margin:1px; background:green;}
    </style>
    </head>
    <body>
    <div id="parent">
    <div id="child"></div>
    </div>
    </body>
    </html>
    But the second doesn't:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <style type="text/css">
    #parent {width:101px; height:102px; background:red; overflow:auto;}
    #child {width:100px; height:100px; margin:1px; background:green;}
    </style>
    </head>
    <body>
    <div id="parent">
    <div id="child"></div>
    </div>
    </body>
    </html>
    Why is that?
    Thanks!
    Last edited by Rain Lover; 11-06-2012 at 06:42 AM.

  • #2
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Use scroll on the overflow rather than auto?
    http://www.w3schools.com/cssref/pr_pos_overflow.asp
    Last edited by stephen_; 11-06-2012 at 01:18 PM.

  • #3
    Regular Coder
    Join Date
    Nov 2009
    Posts
    170
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by stephen_ View Post
    Use scroll on the overflow rather than auto?
    http://www.w3schools.com/cssref/pr_pos_overflow.asp
    Not the answer to my question.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,672
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Rain Lover,
    It's as if overflow: auto; does not recognize that 1px of margin as overflow, but only when it adds to the width. How weird is that?

    I'm watching this thread to see if any of the smart guys on this forum have any idea what's going on.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

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