margin-collapse-clear-010

Margin Collapsing with Clearance

WeasyPrint

This browser

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: Margin Collapsing with Clearance</title>
 5   <link rel="author" title="Microsoft" href="http://microsoft.com/">
 6   <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#flow-control">
 7   <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">
 8   <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#floats">
 9   <style type="text/css">
10     div.target1 { position: absolute; left: -20px; height: 50px; width: 0; border-left: 15px solid yellow; top: 0px; }
11     div.target2 { position: absolute; left: -20px; height: 20px; width: 0; border-left: 5px solid aqua; top: 100px; }
12     div.target3 { position: absolute; left: -20px; height: 30px; width: 0; border-left: 5px solid silver; top: 120px; }
13     div.target4 { position: absolute; left: -15px; height: 50px; width: 0; border-left: 5px solid orange; top: 100px; }
14     div.target5 { position: absolute; left: -10px; height: 50px; width: 0; border-left: 5px solid silver; top: 100px; }
15     div.container { width: 150px; position: relative; margin-left: 20px; border: solid thin; }
16     div.box1 { height: 50px; background-color: yellow; }
17     div.parentof2and3 { background-color: silver; padding-right: 10px; }
18     div.box2 { background-color: aqua; float: left; width: 20px; height: 20px; }
19     div.box3 { overflow: hidden; margin-top: 50px; height: 50px; background-color: orange; }
20   </style>
21  </head>
22  <body>
23   <p>The coloured bars on the left should match the coloured boxes in the black box.</p>
24   <div class="container">
25     <div class="target1"></div>
26     <div class="target2"></div>
27     <div class="target3"></div>
28     <div class="target4"></div>
29     <div class="target5"></div>
30     <div class="box1">A</div>
31     <div class="parentof2and3">
32       <div class="box2">B</div>
33       <div class="box3">C</div>
34     </div>
35   </div>
36  </body>
37 </html>