margin-collapse-clear-004

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   <style type="text/css">
 9     div.target1 { position: absolute; left: -20px; height: 50px; width: 0; border-left: 15px solid yellow; top: 0px; }
10     div.target2 { position: absolute; left: -20px; height: 20px; width: 0; border-left: 5px solid aqua; border-right: 5px solid orange; top: 100px; }
11     div.target3 { position: absolute; left: -20px; height: 30px; width: 0; border-left: 10px solid orange; top: 120px; }
12     div.target4 { position: absolute; left: -10px; height: 50px; width: 0; border-left: 5px solid silver; top: 100px; }
13     div.container { width: 150px; position: relative; margin-left: 20px; border: solid thin; }
14     div.box1 { height: 50px; background-color: yellow; }
15     div.parentof2and3 { background-color: silver; padding-right: 10px; }
16     div.box2 { background-color: aqua; float: left; width: 20px; height: 20px; }
17     div.box3 { margin-top: 50px; height: 50px; background-color: orange; }
18   </style>
19  </head>
20  <body>
21   <p>The coloured bars on the left should match the coloured boxes in the black box.</p>
22   <div class="container">
23     <div class="target1"></div>
24     <div class="target2"></div>
25     <div class="target3"></div>
26     <div class="target4"></div>
27     <div class="box1">A</div>
28     <div class="parentof2and3">
29       <div class="box2">B</div>
30       <div class="box3">C</div>
31     </div>
32   </div>
33  </body>
34 </html>