multicol-nested-margin-004.xht (2495B)
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-004-ref.xht" /> 9 <meta name="flags" content="ahem" /> 10 <meta name="assert" content="This test checks that due to a top margin only set on the first child element of a nested multicol element that will not collapse with the margins of the multicol element, then the height of an multi-column element can make its other inner multi-column (with a zero margin-top) element break into its own column boxes." /> 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: yellow; 26 color: black; 27 margin: 1em; 28 orphans: 1; 29 widows: 1; 30 31 column-count: 3; 32 column-gap: 1em; 33 } 34 35 div div {margin: 0 1em;} 36 37 div div:first-child {margin: 1em 1em 0;} 38 39 /* 40 41 N == 3; 42 43 43em - 2em (horizontal margins) == available-width 44 45 W == max(0, (available-width - ((N - 1) * column-gap)) / N); 46 W == max(0, (41em - ((3 - 1) * 1em)) / 3); 47 W == max(0, (41em - (2 * 1em)) / 3); 48 W == max(0, (41em - 2em) / 3); 49 W == max(0, 39em / 3); 50 W == max(0, 13em); 51 W == 13em; 52 53 13em : width of each outer column box 54 - 55 2em : horizontal margin of each div inside 56 ======= 57 11em : width of each inner multi-column elements 58 59 N == 3; 60 61 W == max(0, (available-width - ((N - 1) * column-gap)) / N); 62 W == max(0, (11em - ((3 - 1) * 1em)) / 3); 63 W == max(0, (11em - (2 * 1em)) / 3); 64 W == max(0, (11em - 2em) / 3); 65 W == max(0, 9em / 3); 66 W == max(0, 3em); 67 W == 3em; 68 69 */ 70 71 div div:nth-child(2) {color: pink;} 72 73 div div:nth-child(3) {color: blue;} 74 ]]></style> 75 </head> 76 77 <body> 78 79 <div> 80 <div> 81 bl ac 82 bl ac 83 bl ac 84 bl ac 85 </div> 86 <div> 87 Pi nk 88 Pi nk 89 Pi nk 90 Pi nk 91 </div> 92 <div> 93 bl ue 94 bl ue 95 bl ue 96 bl ue 97 </div> 98 </div> 99 100 </body> 101 </html>