flex-aspect-ratio-025.html (3974B)
1 <!DOCTYPE html> 2 <html> 3 <title>CSS aspect-ratio: Test flex item's resolved width/min-width with border-box box-sizing in a row flex container</title> 4 <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> 5 <link rel="author" title="Mozilla" href="https://www.mozilla.org/"> 6 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio"> 7 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum"> 8 <link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#min-size-auto"> 9 <link rel="match" href="../../reference/ref-filled-green-200px-square.html" /> 10 <style> 11 .flexContainer { 12 display: flex; 13 flex-direction: row; 14 width: 1px; 15 } 16 .item { 17 background: green; 18 padding-top: 15px; 19 padding-left: 10px; 20 box-sizing: border-box; 21 } 22 </style> 23 24 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 25 26 <!-- In all of the subtests here, each flex item's automatic minimum width is 27 resolved directly from its content size suggestion. Notably, these items 28 *do not* get a "transferred size suggestion", because they are all 29 *non-replaced* elements; and "transferred size suggestion" is only used 30 for resolving automatic minimum sizes on *replaced* elements. However, 31 note that we do "transfer" sizes through the aspect ratio, as part of 32 computing the content size suggestion and/or flex base size. --> 33 34 <!-- In the following four flex containers, the aspect-ratio works with border-box. --> 35 <div class="flexContainer" style="width: auto;"> 36 <!-- The border-box height 25px is transferred to the main axis, 37 yielding a resolved flex base size (border-box) of 200px. --> 38 <div class="item" style="min-width:0; height: 25px; aspect-ratio: 8/1;"></div> 39 </div> 40 41 <div class="flexContainer"> 42 <!-- The content size suggestion (border-box) is 200px because the 43 border-box height 25px is transferred to the main axis. --> 44 <div class="item" style="height: 25px; aspect-ratio: 8/1;"></div> 45 </div> 46 47 <div class="flexContainer"> 48 <!-- The content size suggestion (border-box) is 200px because the 49 border-box height 25px (enforced by min-height) is transferred to the 50 main axis. --> 51 <div class="item" style="min-height: 25px; aspect-ratio: 8/1;"></div> 52 </div> 53 54 <div class="flexContainer"> 55 <!-- The content size suggestion (border-box) is 200px because the 56 border-box height 25px (clamped by max-height) is transferred to the 57 main axis. --> 58 <div class="item" style="max-height: 25px; height: 100px; aspect-ratio: 8/1;"></div> 59 </div> 60 61 <!-- In the following four flex containers, the aspect-ratio works with content-box 62 because its value contains 'auto'. --> 63 <div class="flexContainer" style="width: auto;"> 64 <!-- The content-box height 10px is transferred to the main axis, 65 yielding a resolved flex base size (content-box) of 190px. --> 66 <div class="item" style="min-width:0; height: 25px; aspect-ratio: auto 19/1;"></div> 67 </div> 68 69 <div class="flexContainer"> 70 <!-- The content size suggestion (content-box) is 190px because the 71 content-box height 10px is transferred to the main axis. --> 72 <div class="item" style="height: 25px; aspect-ratio: auto 19/1;"></div> 73 </div> 74 75 <div class="flexContainer"> 76 <!-- The content size suggestion (content-box) is 190px because the 77 content-box height 10px (enforced by min-height) is transferred to the 78 main axis. --> 79 <div class="item" style="min-height: 25px; aspect-ratio: auto 19/1;"></div> 80 </div> 81 82 <div class="flexContainer"> 83 <!-- The content size suggestion (content-box) is 190px because the 84 content-box height 10px (clamped by max-height) is transferred to the 85 main axis. --> 86 <div class="item" style="max-height: 25px; height: 100px; aspect-ratio: auto 19/1;"></div> 87 </div> 88 </html>