grid-item-intrinsic-ratio-normal-001-ref.html (5507B)
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: stretching intrinsic ratio item with 'normal' and/or 'stretch', with no Automatic Minimum Size clamping</title> 9 <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1315383"> 10 <style type="text/css"> 11 .grid { 12 display: inline-grid; 13 border: 1px solid; 14 margin: 5px; 15 grid-template-columns: repeat(7, min-content); 16 grid-auto-rows: min-content; 17 grid-column-gap: 10px; 18 align-items: start; 19 justify-items: start; 20 } 21 22 img { min-width:0; min-height:0; } 23 24 x { width:32px; height:2px; background:cyan; } 25 .w24 > x { width:24px; } 26 .w8 > x { width:8px; } 27 .w4 > x { width:4px; } 28 29 </style> 30 </head> 31 <body> 32 33 <div class="grid" style="grid:24px 10px 24px / repeat(7, 32px); grid-column-gap: 10px;"> 34 <div style="height:24px; width:2px; background:cyan; grid-row:1"></div> 35 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 36 <div style="height:24px; grid-row:3"></div> 37 <x style="grid-row:4"></x> 38 </div> 39 40 <br> 41 42 <div class="grid w24" style="grid:32px 10px 32px / repeat(7, 24px); grid-column-gap: 10px;"> 43 <div style="height:32px; width:2px; background:cyan; grid-row:1"></div> 44 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 45 <div style="height:32px; grid-row:3"></div> 46 <x style="grid-row:4"></x> 47 </div> 48 49 <br> 50 51 <div class="grid w4" style="grid:8px 10px 8px / repeat(7, 4px); grid-column-gap:32px; "> 52 <div style="height:8px; width:2px; background:cyan; grid-row:1"></div> 53 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 54 <div style="height:8px; grid-row:3"></div> 55 <x style="grid-row:4"></x> 56 </div> 57 58 <br> 59 60 <div class="grid w4" style="grid:32px 10px 32px / repeat(7, 4px); grid-column-gap:32px; "> 61 <div style="height:32px; width:2px; background:cyan; grid-row:1"></div> 62 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 63 <div style="height:32px; grid-row:3"></div> 64 <x style="grid-row:4"></x> 65 </div> 66 67 <br> 68 69 <div class="grid w8" style="grid:repeat(3, 4px) / repeat(7, 8px); grid-gap:8px; "> 70 <div style="height:4px; width:2px; background:cyan; grid-row:1"></div> 71 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 72 <div style="height:4px; grid-row:3"></div> 73 <x style="grid-row:4"></x> 74 </div> 75 76 <br> 77 78 <div class="grid" style="grid:repeat(3, 8px) / repeat(7, 32px); grid-gap:16px; "> 79 <div style="height:4px; width:2px; background:cyan; grid-row:1"></div> 80 <div style="height:10px; grid-row:2; grid-column: span 7"></div> 81 <div style="height:4px; grid-row:3"></div> 82 <x style="grid-row:4"></x> 83 </div> 84 85 <br> 86 87 <script> 88 var url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAEElEQVQoz2NgGAWjYBTAAAADEAABaJFtwwAAAABJRU5ErkJggg%3D%3D"; 89 var grids = document.querySelectorAll('.grid'); 90 var js = [ "normal", "start", "center", "stretch" ]; 91 var as = [ "normal", "start", "center", "stretch" ]; 92 var imgSizes = 93 [ 94 ['16px', '16px'], 95 ['16px', '16px'], 96 ['16px', '16px'], 97 ['24px', '24px'], 98 ['16px', '16px'], 99 ['24px', '24px'], 100 ['16px', '16px'], 101 ['24px', '24px'], 102 ['32px', '32px'], 103 ['32px', '32px'], 104 ['32px', '32px'], 105 ['32px', '24px'], 106 ['16px', '16px'], 107 ['16px', '16px'], 108 ['16px', '16px'], 109 ['32px', '32px'], 110 ['16px', '16px'], 111 ['32px', '32px'], 112 ['16px', '16px'], 113 ['32px', '32px'], 114 ['24px', '24px'], 115 ['24px', '24px'], 116 ['24px', '24px'], 117 ['24px', '32px'], 118 ['16px', '16px'], 119 ['16px', '16px'], 120 ['16px', '16px'], 121 ['8px', '8px'], 122 ['16px', '16px'], 123 ['8px', '8px'], 124 ['16px', '16px'], 125 ['8px', '8px'], 126 ['4px', '4px'], 127 ['4px', '4px'], 128 ['4px', '4px'], 129 ['4px', '8px'], 130 ['16px', '16px'], 131 ['16px', '16px'], 132 ['16px', '16px'], 133 ['32px', '32px'], 134 ['16px', '16px'], 135 ['32px', '32px'], 136 ['16px', '16px'], 137 ['32px', '32px'], 138 ['4px', '4px'], 139 ['4px', '4px'], 140 ['4px', '4px'], 141 ['4px', '32px'], 142 ['16px', '16px'], 143 ['16px', '16px'], 144 ['16px', '16px'], 145 ['4px', '4px'], 146 ['16px', '16px'], 147 ['4px', '4px'], 148 ['16px', '16px'], 149 ['4px', '4px'], 150 ['8px', '8px'], 151 ['8px', '8px'], 152 ['8px', '8px'], 153 ['8px', '4px'], 154 ['16px', '16px'], 155 ['16px', '16px'], 156 ['16px', '16px'], 157 ['8px', '8px'], 158 ['16px', '16px'], 159 ['8px', '8px'], 160 ['16px', '16px'], 161 ['8px', '8px'], 162 ['32px', '32px'], 163 ['32px', '32px'], 164 ['32px', '32px'], 165 ['32px', '8px'], 166 ]; 167 var index = 0; // imgSizes index 168 for (var i = 0; i < grids.length; ++i) { 169 for (var j = 0; j < js.length; j++) { 170 for (var a = 0; a < as.length; a++) { 171 if (as[a] != "normal" && as[a] != "stretch" && 172 js[j] != "normal" && js[j] != "stretch") { 173 continue; 174 } 175 var img = document.createElement('img'); 176 img.style.width = imgSizes[index][0]; 177 img.style.height = imgSizes[index][1]; 178 if (as[a] != "normal" && as[a] != "stretch") 179 img.style.alignSelf = as[a]; 180 if (js[j] != "normal" && js[j] != "stretch") 181 img.style.justifySelf = js[j]; 182 img.src = url; 183 img.setAttribute('title', as[a] + ' / ' + js[j]); 184 grids[i].appendChild(img); 185 index++; 186 } 187 } 188 for (var j = 0; j < js.length; j++) { 189 for (var a = 0; a < as.length; a++) { 190 if (as[a] != "normal" && as[a] != "stretch" && 191 js[j] != "normal" && js[j] != "stretch") { 192 continue; 193 } 194 var x = document.createElement('x'); 195 grids[i].appendChild(x); 196 } 197 } 198 } 199 </script> 200 201 </body> 202 </html>