margin-collapse-163.xht (1336B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: Margin collapsing with floats before self collapsing children with margins not collapsing with parent</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/063.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 /* This test requires half-decent z-index support */ 10 html { margin: 0; padding: 0; } 11 body { margin: 0 10px; padding: 0; } 12 .a { position: absolute; top: 13px; left: 10px; width: 20em; height: 4em; background: red; color: yellow; z-index: -1; } 13 .b { float: left; width: 20em; height: 4em; background: green; color: white; } 14 .c1 { margin: 2px; padding-top: 1px; } /* prevent collapsing with parent */ 15 .c2 { margin: -4px 20px; } 16 .c3 { margin: 0 0 14px; } 17 .c4 { margin: 50px; } 18 </style> 19 </head> 20 <body> 21 <div class="c1"> 22 <div class="c2"> 23 <div class="c3"></div> 24 </div> 25 </div> 26 <div class="a">FAIL</div> 27 <div class="b">This block should be green.</div> 28 <div class="c4"></div> 29 30 31 </body> 32 </html>