multicol-nested-margin-003.xht (2271B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Multi-column Layout Test: nested multicolumn and nested margin-top</title> 5 <link rel="author" title="Opera Software ASA" href="http://www.opera.com/" /> 6 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> <!-- 2013-08-14 --> 7 <link rel="help" href="http://www.w3.org/TR/css3-multicol/#the-multi-column-model" title="2. The multi-column model" /> 8 <link rel="match" href="multicol-nested-margin-003-ref.xht" /> 9 <meta name="flags" content="ahem" /> 10 <meta name="assert" content="This test checks that a top margin set on the first child element of a nested multicol element will not collapse with the margins of the multicol element." /> 11 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 12 <style type="text/css"><![CDATA[ 13 body > div 14 { 15 font: 1.25em/1 Ahem; 16 margin: 1em; 17 width: 41em; 18 /* 19 This test requires a viewport width of 860px 20 */ 21 } 22 23 div 24 { 25 background-color: yellow; 26 color: black; 27 margin: 1em 1em 0; 28 orphans: 1; 29 widows: 1; 30 31 column-count: 3; 32 column-gap: 1em; 33 } 34 35 /* 36 37 N == 3; 38 39 43em - 2em (horizontal margins) == available-width 40 41 W == max(0, (available-width - ((N - 1) * column-gap)) / N); 42 W == max(0, (41em - ((3 - 1) * 1em)) / 3); 43 W == max(0, (41em - (2 * 1em)) / 3); 44 W == max(0, (41em - 2em) / 3); 45 W == max(0, 39em / 3); 46 W == max(0, 13em); 47 W == 13em; 48 49 13em : width of each outer column box 50 - 51 2em : horizontal margin of each div inside 52 ======= 53 11em : width of each inner multi-column elements 54 55 N == 3; 56 57 W == max(0, (available-width - ((N - 1) * column-gap)) / N); 58 W == max(0, (11em - ((3 - 1) * 1em)) / 3); 59 W == max(0, (11em - (2 * 1em)) / 3); 60 W == max(0, (11em - 2em) / 3); 61 W == max(0, 9em / 3); 62 W == max(0, 3em); 63 W == 3em; 64 65 */ 66 67 div div:nth-child(2) {color: pink;} 68 69 div div:nth-child(3) {color: blue;} 70 ]]></style> 71 </head> 72 73 <body> 74 75 <div> 76 <div> 77 bl ac 78 bl ac 79 bl ac 80 bl ac 81 </div> 82 <div> 83 Pi nk 84 Pi nk 85 Pi nk 86 Pi nk 87 </div> 88 <div> 89 bl ue 90 bl ue 91 bl ue 92 bl ue 93 </div> 94 </div> 95 96 </body> 97 </html>