grid-justify-content-003-ref.html (3321B)
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: Testing track fallback values</title> 9 <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151214"> 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 27 x { background: lime; height:7px; } 28 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", "4", "5", "6", "7", "8", "9" ]; 64 var widths = [ "0", "1", "2", "3", "4", "5", "6" ]; 65 for (var j = 0; j < justify.length; ++j) { 66 // document.body.appendChild(document.createTextNode(justify[j])); // for debugging 67 var chunk = document.createElement('div'); 68 chunk.setAttribute("style", "border:1px solid; padding:2px 10px; overflow:hidden"); 69 for (var c = 0; c < cols.length; ++c) { 70 for (var w = 0; w < widths.length; ++w) { 71 // set this to true if you want to see all tests 72 var run_test = widths[w] < cols[c] || cols[c] == 0 || cols[c] == 1; 73 if (run_test) { 74 var grid = document.createElement('div'); 75 grid.style.width = widths[w]+"px"; 76 grid.className = "grid"; 77 grid.style.justifyContent = justify[j]; 78 var span = document.createElement('span'); 79 span.style.gridColumn = "1 / span " + cols[c]; 80 grid.appendChild(span); 81 for (var x = 0; x < cols[c]; ++x) { 82 grid.appendChild(document.createElement('x')); 83 } 84 // if (j < 5) { // The stretch tests. 85 if (j < 1) { // The stretch test. 86 if (c == 1) 87 grid.style.background = 'pink' 88 } 89 // if (j == 6 && cols[c] == 1) { // The 'safe end' tests. 90 if (j == 2 && cols[c] == 1) { // The 'safe end' tests. 91 if (widths[w] != 0) grid.style.justifyContent = 'end'; 92 } 93 // if (j == 7 && cols[c] == 1) { // The 'safe center' tests. 94 if (j == 3 && cols[c] == 1) { // The 'safe center' tests. 95 if (widths[w] != 0) grid.style.justifyContent = 'center'; 96 } 97 // if (j > 15) { // The space-around and space-evenly tests. 98 if (j > 7) { // The space-around and space-evenly tests. 99 if (cols[c] == 1) { 100 if (widths[w] == 0) { 101 if (grid.style.justifyContent != 'end') { 102 grid.style.justifyContent = 'start'; 103 } 104 } else { 105 grid.style.justifyContent = 'center'; 106 } 107 } 108 } 109 chunk.appendChild(grid); 110 } 111 } 112 } 113 document.body.appendChild(chunk); 114 } 115 document.body.style.display = ""; 116 </script> 117 118 </body> 119 </html>