margin-collapse-133

Margin Collapsing: float positioning

WeasyPrint

This browser

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html lang="en">
 3 <head>
 4   <title>CSS Test: Margin Collapsing: float positioning</title>
 5   <link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch">
 6   <link rel="alternate" href="http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/033.html" type="text/html">
 7   <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">
 8   <style type="text/css">
 9    table, td { padding: 0; border-spacing: 0; }
10    .comparator { border-spacing: 1em; }
11    .test, .control { border: solid; background: lime; }
12 
13    .test .top { display: block; margin: 0; height: 1em; width: 8em; background: yellow; }
14    .test .container { display: block; margin: 1em 0 0 0; width: 8em; background: red; }
15    .test .float { float: left; margin: 0; height: 1em; width: 8em; background: yellow; }
16    .test .block { display: block; margin: 2em 0 0 0; height: 1em; background: red; }
17 
18    .control .lime { border-top: 2em solid lime; width: 8em; }
19    .control .yellow { border-top: 1em solid yellow; }
20   </style>
21  </head>
22  <body>
23   <p>The following two rectangles should be identical.</p>
24   <table class="comparator">
25    <tr>
26     <td class="test">
27 
28      <div class="top"> </div>
29      <div class="container">
30       <div class="float"> </div>
31       <div class="block"> </div>
32      </div>
33 
34     </td>
35     <td class="control">
36      <div class="yellow"> </div>
37      <div class="lime"> </div>
38      <div class="yellow"> </div>
39     </td>
40    </tr>
41   </table>
42  
43 
44 </body>
45 </html>