grid-content-alignment-overflow-002.html (14948B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS Grid Layout Test: content alignment and overflow alignment.</title> 5 <link rel="author" title="Javier Fernandez" href="mailto:jfernandez@igalia.com"> 6 <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> 7 <link rel="help" href="https://drafts.csswg.org/css-grid/#alignment"> 8 <link rel="help" href="https://drafts.csswg.org/css-align-3/#overflow-values"> 9 <link rel="help" href="https://drafts.csswg.org/css-align-3/#distribution-values"> 10 <link rel="help" href="https://drafts.csswg.org/css-align-3/#content-distribution"> 11 <link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=376823"> 12 <link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=249451"> 13 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1527539"> 14 <link rel="stylesheet" href="/css/support/grid.css"> 15 <link rel="stylesheet" href="/css/support/alignment.css"> 16 <link rel="stylesheet" href="/css/support/width-keyword-classes.css"> 17 <meta name="assert" content="Test that the overflow alignment mode is applied correctly for content alignment properties." /> 18 19 <style> 20 body { 21 margin: 0; 22 } 23 24 .container { 25 position: relative; 26 float: left; 27 } 28 29 .grid { 30 grid-template-columns: 50px 50px; 31 grid-template-rows: 100px 100px; 32 padding: 30px; 33 box-sizing: border-box; 34 overflow: hidden; 35 } 36 37 .contentSizedTracks { 38 grid-template: max-content 100px / max-content 50px; 39 } 40 41 .overflowWidth { 42 width: 60px; 43 height: 300px; 44 } 45 46 .overflowHeight { 47 width: 200px; 48 height: 150px; 49 } 50 51 .item1 { 52 width: 50px; 53 height: 150px; 54 } 55 56 .item2 { 57 width: 150px; 58 height: 100px; 59 } 60 61 .minSize { 62 min-width: 300px; 63 min-height: 400px; 64 } 65 66 .maxSize { 67 max-width: 100px; 68 max-height: 100px; 69 } 70 </style> 71 72 <script src="/resources/testharness.js"></script> 73 <script src="/resources/testharnessreport.js"></script> 74 <script src="/resources/check-layout-th.js"></script> 75 </head> 76 77 <body onload="checkLayout('.grid')"> 78 79 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 80 <div class="grid overflowWidth contentCenter" data-expected-width="60" data-expected-height="300" data-expected-scroll-width="110" data-expected-scroll-height="300"> 81 <div class="firstRowFirstColumn" data-offset-x="-20" data-offset-y="50" data-expected-width="50" data-expected-height="100"></div> 82 <div class="secondRowFirstColumn" data-offset-x="-20" data-offset-y="150" data-expected-width="50" data-expected-height="100"></div> 83 <div class="firstRowSecondColumn" data-offset-x="30" data-offset-y="50" data-expected-width="50" data-expected-height="100"></div> 84 <div class="secondRowSecondColumn" data-offset-x="30" data-offset-y="150" data-expected-width="50" data-expected-height="100"></div> 85 </div> 86 </div> 87 <div>Grid container width of 60px not enough for 2 column tracks of 50px.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>default</b></div> 88 89 <br clear="all"> 90 91 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 92 <div class="grid overflowHeight contentCenterUnsafe" data-expected-width="200" data-expected-height="150" data-expected-scroll-width="200" data-expected-scroll-height="205"> 93 <div class="firstRowFirstColumn" data-offset-x="50" data-offset-y="-25" data-expected-width="50" data-expected-height="100"></div> 94 <div class="secondRowFirstColumn" data-offset-x="50" data-offset-y="75" data-expected-width="50" data-expected-height="100"></div> 95 <div class="firstRowSecondColumn" data-offset-x="100" data-offset-y="-25" data-expected-width="50" data-expected-height="100"></div> 96 <div class="secondRowSecondColumn" data-offset-x="100" data-offset-y="75" data-expected-width="50" data-expected-height="100"></div> 97 </div> 98 </div> 99 <div>Grid container height of 150px not enough for 2 row tracks of 100px.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>unsafe</b></div> 100 101 <br clear="all"> 102 103 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 104 <div class="grid overflowWidth contentCenterSafe" data-expected-width="60" data-expected-height="300" data-expected-scroll-width="160" data-expected-scroll-height="300"> 105 <div class="firstRowFirstColumn" data-offset-x="30" data-offset-y="50" data-expected-width="50" data-expected-height="100"></div> 106 <div class="secondRowFirstColumn" data-offset-x="30" data-offset-y="150" data-expected-width="50" data-expected-height="100"></div> 107 <div class="firstRowSecondColumn" data-offset-x="80" data-offset-y="50" data-expected-width="50" data-expected-height="100"></div> 108 <div class="secondRowSecondColumn" data-offset-x="80" data-offset-y="150" data-expected-width="50" data-expected-height="100"></div> 109 </div> 110 </div> 111 <div>Grid container width of 60px not enough for 2 column tracks of 50px.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>safe</b></div> 112 113 <br clear="all"> 114 115 <div class="container" style="margin-bottom: 75px; margin-right: 25px;"> 116 <div class="grid overflowHeight contentCenterSafe" data-expected-width="200" data-expected-height="150" data-expected-scroll-width="200" data-expected-scroll-height="260"> 117 <div class="firstRowFirstColumn" data-offset-x="50" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 118 <div class="secondRowFirstColumn" data-offset-x="50" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 119 <div class="firstRowSecondColumn" data-offset-x="100" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 120 <div class="secondRowSecondColumn" data-offset-x="100" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 121 </div> 122 </div> 123 <div>Grid container height of 150px not enough for 2 row tracks of 100px.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>safe</b></div> 124 125 <br clear="all"> 126 127 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 128 <div class="grid overflowWidth contentEnd" data-expected-width="60" data-expected-height="300" data-expected-scroll-width="60" data-expected-scroll-height="300"> 129 <div class="firstRowFirstColumn" data-offset-x="-70" data-offset-y="70" data-expected-width="50" data-expected-height="100"></div> 130 <div class="secondRowFirstColumn" data-offset-x="-70" data-offset-y="170" data-expected-width="50" data-expected-height="100"></div> 131 <div class="firstRowSecondColumn" data-offset-x="-20" data-offset-y="70" data-expected-width="50" data-expected-height="100"></div> 132 <div class="secondRowSecondColumn" data-offset-x="-20" data-offset-y="170" data-expected-width="50" data-expected-height="100"></div> 133 </div> 134 </div> 135 <div>Grid container width of 60px not enough for 2 column tracks of 50px.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>default</b></div> 136 137 <br clear="all"> 138 139 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 140 <div class="grid overflowHeight contentEndUnsafe" data-expected-width="200" data-expected-height="150" data-expected-scroll-width="200" data-expected-scroll-height="150"> 141 <div class="firstRowFirstColumn" data-offset-x="70" data-offset-y="-80" data-expected-width="50" data-expected-height="100"></div> 142 <div class="secondRowFirstColumn" data-offset-x="70" data-offset-y="20" data-expected-width="50" data-expected-height="100"></div> 143 <div class="firstRowSecondColumn" data-offset-x="120" data-offset-y="-80" data-expected-width="50" data-expected-height="100"></div> 144 <div class="secondRowSecondColumn" data-offset-x="120" data-offset-y="20" data-expected-width="50" data-expected-height="100"></div> 145 </div> 146 </div> 147 <div>Grid container height of 150px not enough for 2 row tracks of 100px.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>unsafe</b></div> 148 149 <br clear="all"> 150 151 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 152 <div class="grid overflowWidth contentEndSafe" data-expected-width="60" data-expected-height="300" data-expected-scroll-width="160" data-expected-scroll-height="300"> 153 <div class="firstRowFirstColumn" data-offset-x="30" data-offset-y="70" data-expected-width="50" data-expected-height="100"></div> 154 <div class="secondRowFirstColumn" data-offset-x="30" data-offset-y="170" data-expected-width="50" data-expected-height="100"></div> 155 <div class="firstRowSecondColumn" data-offset-x="80" data-offset-y="70" data-expected-width="50" data-expected-height="100"></div> 156 <div class="secondRowSecondColumn" data-offset-x="80" data-offset-y="170" data-expected-width="50" data-expected-height="100"></div> 157 </div> 158 </div> 159 <div>Grid container width of 60px not enough for 2 column tracks of 50px.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>safe</b></div> 160 161 <br clear="all"> 162 163 <div class="container" style="margin-bottom: 75px; margin-right: 25px;"> 164 <div class="grid overflowHeight contentEndSafe" data-expected-width="200" data-expected-height="150" data-expected-scroll-width="200" data-expected-scroll-height="260"> 165 <div class="firstRowFirstColumn" data-offset-x="70" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 166 <div class="secondRowFirstColumn" data-offset-x="70" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 167 <div class="firstRowSecondColumn" data-offset-x="120" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 168 <div class="secondRowSecondColumn" data-offset-x="120" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 169 </div> 170 </div> 171 <div>Grid container height of 150px not enough for 2 row tracks of 100px.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>safe</b></div> 172 173 <br clear="all"> 174 175 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 176 <div class="grid fit-content contentEndUnsafe" data-expected-width="160" data-expected-height="260" data-expected-scroll-width="160" data-expected-scroll-height="260"> 177 <div class="firstRowFirstColumn" data-offset-x="30" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 178 <div class="secondRowFirstColumn" data-offset-x="30" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 179 <div class="firstRowSecondColumn" data-offset-x="80" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 180 <div class="secondRowSecondColumn" data-offset-x="80" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 181 </div> 182 </div> 183 <div>Grid container indefinite size using fit-content, hence no possible overflow.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>unsafe</b></div> 184 185 <br clear="all"> 186 187 <div class="container" style="margin-bottom: 200px; margin-right: 25px;"> 188 <div class="grid fit-content contentCenterUnsafe" data-expected-width="160" data-expected-height="260" data-expected-scroll-width="160" data-expected-scroll-height="260"> 189 <div class="firstRowFirstColumn" data-offset-x="30" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 190 <div class="secondRowFirstColumn" data-offset-x="30" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 191 <div class="firstRowSecondColumn" data-offset-x="80" data-offset-y="30" data-expected-width="50" data-expected-height="100"></div> 192 <div class="secondRowSecondColumn" data-offset-x="80" data-offset-y="130" data-expected-width="50" data-expected-height="100"></div> 193 </div> 194 </div> 195 <div>Grid container indefinite size using fit-content, hence no possible overflow.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>unsafe</b></div> 196 197 <br clear="all"> 198 199 <div class="container" style="margin-bottom: 100px; margin-right: 25px;"> 200 <div class="grid contentSizedTracks fit-content maxSize contentEndUnsafe" data-expected-width="100" data-expected-height="100" data-expected-scroll-width="100" data-expected-scroll-height="100"> 201 <div class="item1 firstRowSecondColumn" data-offset-x="20" data-offset-y="-180" data-expected-width="50" data-expected-height="150"></div> 202 <div class="item2 secondRowFirstColumn" data-offset-x="-130" data-offset-y="-30" data-expected-width="150" data-expected-height="100"></div> 203 </div> 204 </div> 205 <div>Grid container indefinite size using fit-content, but max-size constraints implies that the content-sized tracks overflow.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>unsafe</b></div> 206 207 <br clear="all"> 208 209 <div class="container" style="margin-bottom: 100px; margin-right: 75px;"> 210 <div class="grid contentSizedTracks fit-content maxSize contentCenterUnsafe" data-expected-width="100" data-expected-height="100" data-expected-scroll-width="180" data-expected-scroll-height="205"> 211 <div class="item1 firstRowSecondColumn" data-offset-x="100" data-offset-y="-75" data-expected-width="50" data-expected-height="150"></div> 212 <div class="item2 secondRowFirstColumn" data-offset-x="-50" data-offset-y="75" data-expected-width="150" data-expected-height="100"></div> 213 </div> 214 </div> 215 <div>Grid container indefinite size using fit-content, but max-size constraints implies that the content-sized tracks overflow.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>unsafe</b></div> 216 217 <br clear="all"> 218 219 <div class="container" style="margin-bottom: 50px; margin-right: 25px;"> 220 <div class="grid contentSizedTracks fit-content minSize contentEndUnsafe" data-expected-width="300" data-expected-height="400" data-expected-scroll-width="300" data-expected-scroll-height="400"> 221 <div class="item1 firstRowSecondColumn" data-offset-x="220" data-offset-y="120" data-expected-width="50" data-expected-height="150"></div> 222 <div class="item2 secondRowFirstColumn" data-offset-x="70" data-offset-y="270" data-expected-width="150" data-expected-height="100"></div> 223 </div> 224 </div> 225 <div>Grid container indefinite size using fit-content, but min-size constraints implies that the content-sized tracks don't overflow.<br> Content-Alignment: <b>end</b> and Overflow-Alignment: <b>unsafe</b></div> 226 227 <br clear="all"> 228 229 <div class="container" style="margin-right: 25px;"> 230 <div class="grid contentSizedTracks fit-content minSize contentCenterUnsafe" data-expected-width="300" data-expected-height="400" data-expected-scroll-width="300" data-expected-scroll-height="400"> 231 <div class="item1 firstRowSecondColumn" data-offset-x="200" data-offset-y="75" data-expected-width="50" data-expected-height="150"></div> 232 <div class="item2 secondRowFirstColumn" data-offset-x="50" data-offset-y="225" data-expected-width="150" data-expected-height="100"></div> 233 </div> 234 </div> 235 <div>Grid container indefinite size using fit-content, but min-size constraints implies that the content-sized tracks don't overflow.<br> Content-Alignment: <b>center</b> and Overflow-Alignment: <b>unsafe</b></div> 236 237 <br clear="all"> 238 239 </body> 240 </html>