margin-collapse-035

margin collapsing - clear

WeasyPrint

This browser

Assertion
Margin-top of following siblings of a block on which 'clear' has been set (to a different value than 'none') must not be substracted when calculating clearance. When an element's own margins collapse, and that element has had clearance applied to it, its top margin collapses with the adjoining margins of following siblings.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3 
 4  <head>
 5 
 6   <title>CSS Test: margin collapsing - clear</title>
 7 
 8   <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
 9   <link rel="author" title="Matt Bradley" href="http://www.inventpartners.com/content/contact">
10   <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">
11   <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#flow-control">
12   <meta content="" name="flags">
13   <meta content="Margin-top of following siblings of a block on which 'clear' has been set (to a different value than 'none') must not be substracted when calculating clearance. When an element's own margins collapse, and that element has had clearance applied to it, its top margin collapses with the adjoining margins of following siblings." name="assert">
14 
15   <style type="text/css">
16   p {margin: 8px 0px 0px;}
17 
18   div#overlapped-red
19   {
20   background-color: red;
21   height: 300px;
22   position: absolute;
23   width: 300px;
24   z-index: -1;
25   }
26 
27   div#overlapping-green-container
28   {
29   background-color: green;
30   width: 300px;
31   }
32 
33   div#floated-left
34   {
35   float: left;
36   height: 100px;
37   }
38 
39   div#floated-right
40   {
41   float: right;
42   height: 100px;
43   }
44 
45   div#clear-both {clear: both;}
46 
47   div#following-sibling
48   {
49   height: 50px;
50   margin-top: 150px;
51   }
52   </style>
53 
54  </head>
55 
56  <body>
57 
58   <p>Test passes if there is a big filled green square and <strong>no red</strong></p>
59 
60   <div id="overlapped-red"></div>
61 
62   <div id="overlapping-green-container">
63     <div id="floated-left"></div>
64 
65     <div id="floated-right"></div>
66 
67     <div id="clear-both"></div>
68 
69     <div id="following-sibling"></div>
70   </div>
71 
72  </body>
73 </html>