margin-collapse-039.xht (2294B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 5 <head> 6 7 <title>CSS Test: margin collapsing - clear with child margin</title> 8 9 <!-- 10 Inspired by 11 http://test.csswg.org/suites/css2.1/20110323/html4/c5525-fltmult-000.htm 12 --> 13 14 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 15 <link rel="reviewer" title="Arron Eicholz" href="arronei(at)gmail.com" /> <!-- 2013-07-30 --> 16 <link rel="bookmark" href="http://lists.w3.org/Archives/Public/public-css-testsuite/2012Jan/0022.html" title="[RC6] c5525-fltmult-000 imprecise and failed by several browsers" /> 17 <link rel="help" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins" title="8.3.1 Collapsing margins" /> 18 <link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> 19 20 <meta name="assert" content="An element on which 'clear' is set to a value other than 'none' can have its own margin-top collapse with its first inflow block-level child as long as no line boxes, no clearance, no padding and no border separate them." /> 21 22 <style type="text/css"><![CDATA[ 23 body {margin: 8px;} 24 25 p {margin: 1em 0em;} 26 27 div#overlapped-red 28 { 29 background-color: red; 30 height: 100px; 31 position: absolute; 32 width: 100px; 33 z-index: -1; 34 } 35 36 div#floated-left 37 { 38 background-color: green; 39 color: green; 40 float: left; 41 font: 1em/1.25 serif; 42 padding: 15px; 43 /* 44 45 15px : padding-top 46 + 47 20px : line box height 48 + 49 15px : padding-bottom 50 ===== 51 50px 52 53 */ 54 width: 70px; 55 } 56 57 div#cleared-left {clear: left;} 58 59 div#child-of-cleared-left 60 { 61 background-color: green; 62 color: green; 63 height: 50px; 64 margin-top: 50px; 65 width: 100px; 66 } 67 68 /* 69 The idea is to have div#cleared-left's margin-top collapse 70 with div#child-of-cleared-left's margin-top. The margin collapsing 71 should occur before calculating clearance. 72 */ 73 ]]></style> 74 75 </head> 76 77 <body> 78 79 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 80 81 <div id="overlapped-red"></div> 82 83 <div id="floated-left">flt lef</div> 84 85 <div id="cleared-left"> 86 <div id="child-of-cleared-left">chld clr</div> 87 </div> 88 89 </body> 90 </html>