Closed
Bug 224151
Opened 23 years ago
Closed 23 years ago
div tag not filling in background-color in some cases
Categories
(Core :: Layout: Block and Inline, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: andrewmeier, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 Firebird/0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 Firebird/0.7
In the page at http://users.amcomputing.com/~andy/mozilla-div-bug.html, the
second div on the page is not filling in the background-color for the div at the
top and bottom of the div.
The size of the missing background for the div at the top is exactly the size of
the top margin for the first child p element and the size of the missing
background is the size of the bottom margin for the last child p element in the
div. Left and right margins are unaffected and if the div has a border, the
background fills in properly.
Reproducible: Always
Steps to Reproduce:
1. Open linked test page.
2. Look at example #2 on the page.
Actual Results:
The div background is missing at top and bottom of the element.
Expected Results:
The div background should be filled in for the full size of the div element.
I tested with the latest nightly of Mozilla and there is a gap between ALL the
div elements and the test case has the new gap plus the above mentioned missing
background sections.
Also, I tested in quirks mode and strict mode and get the same results.
Our behavior is correct. See:
http://www.w3.org/TR/CSS21/box.html#collapsing-margins
http://www.w3.org/TR/CSS21/visudet.html#q19
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 2•23 years ago
|
||
If you look at:
http://www.w3.org/TR/CSS21/box.html#mpb-examples
which is linked to from the documentation you listed, you can see that see that
the containing block is supposed to entirely contain it's children elements (the
yellow background for the ul shines through the margin for the li children).
What mozilla is doing with div elements is not drawing the background color
through the margins for the first and last child elements if they happen to be
paragraphs. Also, Mozilla draws the background fully if the div has a border.
I don't see why a div would have a different background size just because the
div doesn't have a border.
Take a look at http://users.amcomputing.com/~andy/mozilla-div-bug.png
That screenshot should more clearly show where the background of the div isn't
getting filled.
I left the bug marked INVALID just in case I'm missing something but the W3C
example is pretty clear.
Comment 3•23 years ago
|
||
In that example, the UL element has same padding. That stops the margins being
adjacent and so keeps them inside the background of the element. Please reread
sections 8.3.1 and 10.6.3 of the CSS2.1 specification:
http://www.w3.org/TR/CSS21/box.html#collapsing-margins
http://www.w3.org/TR/CSS21/visudet.html#q19
In particular, the following:
# In this specification, the expression collapsing margins means that adjoining
# margins ... of two or more boxes (which may be ... nested) combine to form a
# single margin.
# ...
# The top margin of an in-flow block-level element is adjoining to its first
# in-flow block-level child's top margin if the element has ... no top padding
# ...
# The bottom margin of an in-flow block-level element with a 'height' of 'auto'
# ... is adjoining to its last in-flow block-level child's bottom margin if the
# element has no bottom padding
# ...
# If it has block-level children, the height is the distance between the top
# border-edge of the topmost block-level child box ... and the bottom
# border-edge of the bottommost block-level child box ...
You need to log in
before you can comment on or make changes to this bug.
Description
•