Closed Bug 278170 Opened 21 years ago Closed 21 years ago

Scrollbars appear despite no content overflowing (with top margin set)

Categories

(Core :: Layout, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: Biesinger, Unassigned)

Details

Attachments

(1 file)

The testcase I'm about to attach shows that scrollbars unnecessarily appear when a top margin is set on a first <div> in a document. Notes: - html and body must have height:100% - body may or may not have a margin - removing the margin-top makes the scrollbars disappear. Expected results: - No scrollbar when there is no invisible content
Isn't this a matter of the top margin of the div collapsing with the body margin and thus overflowing the viewport off the top? Though I'm surprised at the area that we end up being able to scroll to a bit...
Replacing the 5px top margin with a 5px white border made the scrollbar go away.
Summary: Scrollbars appear despite no content overflowing (with top and bottom margins set) → Scrollbars appear despite no content overflowing (with top margin set)
urg. I guess. so the margin ends up being applied to the body, instead of the div? I guess I'll just use overflow:hidden; on the html and the body...
OS: Linux → All
also, if the viewport is overflowed at the top, then why can I scroll down instead of up?
So how do you stop the margin collapsing?
Yes, the margin gets applied to the body. Yes, the scroll direction is odd. See comment 2 sentence 2. ;) Neil: You prevent collapse by putting something between the margins (border or padding on the parent, or content in the parent before the child) or by making the child or parent have overflow or be a float, or be absolutely positioned. So actually, maybe just putting position:absolute on the body (and position:relative on the <html>, maybe?) might help.
well, marking invalid I guess. we fixed it by using height:99% instead of 100%, but we'll probably try the position:absolute; idea...
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
7 body { position:absolute; } 8 html { position:relative; } this doesn't seem to help, though...
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: