grid-column-gap-001-ref.html (3805B)
1 <!DOCTYPE HTML> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <html><head> 7 <meta charset="utf-8"> 8 <title>Reference: 'grid-column-gap'</title> 9 <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1176792"> 10 <style type="text/css"> 11 html,body { 12 color:black; background-color:white; font-size:16px; padding:0; margin:0; 13 } 14 15 .grid { 16 display: grid; 17 grid-auto-columns: minmax(1px,auto); 18 grid-template-rows: 0px 7px; 19 border: 2px solid black; 20 float: left; 21 margin-right: 20px; 22 } 23 24 .grid :last-child { background:grey; } 25 .grid :nth-child(2) { background:pink; } 26 .grid .gap { background:transparent; } 27 28 x { background: lime; height:7px; } 29 </style> 30 </head> 31 <body> 32 33 <script> 34 document.body.style.display = "none"; 35 var justify = [ 36 "start", 37 // "end", 38 // "center", 39 // "start", 40 // "end", 41 "start", 42 "start", 43 "start", 44 "start", 45 "end", 46 "center", 47 "safe start", 48 // "end", 49 // "start", 50 // "end safe", 51 // "end", 52 "safe center", 53 // "center", 54 // "end", 55 // "end safe", 56 // "start", 57 "safe center", 58 // "end", 59 // "end safe", 60 // "left", 61 // "end", 62 ]; 63 var cols = [ "0", "1", "2", "3", "8", "9" ]; 64 var widths = [ "0", "1", "5", "6" ]; 65 var gaps = [ "1", "2" ]; 66 for (var j = 0; j < justify.length; ++j) { 67 // document.body.appendChild(document.createTextNode(justify[j])); // for debugging 68 var chunk = document.createElement('div'); 69 chunk.setAttribute("style", "border:1px solid; padding:2px 10px; overflow:hidden"); 70 for (var c = 0; c < cols.length; ++c) { 71 for (var w = 0; w < widths.length; ++w) { 72 // set this to true if you want to see all tests 73 var run_test = widths[w] < cols[c] || cols[c] == 0 || cols[c] == 1; 74 if (run_test) { 75 for (var g = 0; g < gaps.length; ++g) { 76 var grid = document.createElement('div'); 77 grid.style.width = widths[w]+"px"; 78 grid.className = "grid"; 79 grid.style.justifyContent = justify[j]; 80 var span = document.createElement('span'); 81 grid.appendChild(span); 82 var numCols = parseInt(cols[c]); 83 var gapCols = numCols==0 ? 0 : (numCols-1); 84 numCols += gapCols*parseInt(gaps[g]); 85 span.style.gridColumn = "1 / span " + numCols; 86 for (var x = 0; x < numCols; ++x) { 87 var item = document.createElement('x'); 88 if (x % (1+(parseInt(gaps[g]))) != 0) 89 item.className = "gap"; 90 grid.appendChild(item); 91 } 92 // if (j < 5) { // The stretch tests. 93 if (j < 1) { // The stretch test. 94 if (c == 1) 95 grid.style.background = 'pink' 96 } 97 // if (j == 6 && cols[c] == 1) { // The 'safe end' tests. 98 if (j == 2 && cols[c] == 1) { // The 'safe end' tests. 99 if (widths[w] != 0) grid.style.justifyContent = 'end'; 100 } 101 // if (j == 7 && cols[c] == 1) { // The 'safe center' tests. 102 if (j == 3 && cols[c] == 1) { // The 'safe center' tests. 103 if (widths[w] != 0) grid.style.justifyContent = 'center'; 104 } 105 // if (j > 15) { // The space-around and space-evenly tests. 106 if (j > 7) { // The space-around and space-evenly tests. 107 if (cols[c] == 1) { 108 if (widths[w] == 0) { 109 if (grid.style.justifyContent != 'end') { 110 grid.style.justifyContent = 'start'; 111 } 112 } else { 113 grid.style.justifyContent = 'center'; 114 } 115 } 116 } 117 chunk.appendChild(grid); 118 } 119 } 120 } 121 } 122 document.body.appendChild(chunk); 123 } 124 document.body.style.display = ""; 125 </script> 126 127 </body> 128 </html>