margin-collapse-clear-010.xht (2007B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 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>