margin-collapse-034

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-right
34   {
35   float: right;
36   height: 100px;
37   }
38 
39   div#clear-right {clear: right;}
40 
41   div#following-sibling
42   {
43   height: 50px;
44   margin-top: 150px;
45   }
46   </style>
47 
48  </head>
49 
50  <body>
51 
52   <p>Test passes if there is a big filled green square and <strong>no red</strong></p>
53 
54   <div id="overlapped-red"></div>
55 
56   <div id="overlapping-green-container">
57     <div id="floated-right"></div>
58 
59     <div id="clear-right"></div>
60 
61     <div id="following-sibling"></div>
62   </div>
63 
64  </body>
65 </html>