clear-clearance-calculation-003

Clearance calculations - clear box collapsing margins

WeasyPrint

This browser

Assertion
When a cleared element has more top margin than the height of the floated element the margin is collpased with previous in-flow children. The element is then placed at the point of the resulting collapsed margin.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3     <head>
 4         <title>CSS Test: Clearance calculations - clear box collapsing margins</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#flow-control">
 7         <meta name="flags" content="">
 8         <meta name="assert" content="When a cleared element has more top margin than the height of the floated element the margin is collpased with previous in-flow children. The element is then placed at the point of the resulting collapsed margin.">
 9         <!-- C1 = H-MT2 -->
10         <!-- C2 = Max(M1, MT2, MB2) - M1 - MT2 -->
11         <style type="text/css">
12             div
13             {
14                 font: 20px/1em Ahem;
15                 width: 5em;
16             }
17             #parent
18             {
19                 background: url('support/clear-clearance-calculation-003.png');
20                 min-height: 7em;
21                 position: relative;
22             }
23             #div1
24             {
25                 margin-bottom: 1em;
26             }
27             #div2
28             {
29                 float: left;
30                 margin: 0;
31             }
32             #div3
33             {
34                 background: red;
35                 clear: left;
36                 margin-bottom: 5em;
37                 margin-top: 4em;
38             }
39             #div1, #div2, #div4
40             {
41                 background: green;
42                 height: 1em;
43             }
44         </style>
45     </head>
46     <body>
47         <p>Test passes if there is no red on this page.</p>
48         <div id="parent">
49             <div id="div1"></div>
50             <div id="div2"></div>
51             <div id="div3"></div>
52             <div id="div4"></div>
53         </div>
54     </body>
55 </html>