flexbox-min-height-auto-001.html (3954B)
1 <!DOCTYPE html> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <html> 7 <head> 8 <meta charset="utf-8"> 9 <title>CSS Test: Testing min-height:auto</title> 10 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"> 11 <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#min-size-auto"> 12 <link rel="match" href="flexbox-min-height-auto-001-ref.html"> 13 <!-- 14 This testcase tests the used value of "min-height:auto" (the property's 15 initial value) on flex items in a vertical flex container. 16 17 It's supposed to resolve to the smallest of: 18 a) The used 'flex-basis' (taken from 'height'), if 'flex-basis' is at its 19 initial value. 20 b) The computed 'max-height' property 21 c) If there's no intrinsic aspect ratio: the item's min-content height. 22 d) If there is an intrinsic aspect ratio: the item's height derived from 23 the ratio & constraints in the other dimension. 24 25 We measure what the used value is by putting flex items in a small flex 26 container, which will shrink its items down to their min-height. 27 28 This test checks for situations where we should resolve the min-height as 29 (a), (b), or (c) above. Another test will check (d). 30 --> 31 <style> 32 .flexbox { 33 display: flex; 34 flex-direction: column; 35 height: 1px; /* No available space; shrink flex items to min-height */ 36 margin-right: 2px; /* (Just for spacing things out, visually) */ 37 float: left; 38 } 39 40 .flexbox > * { 41 /* Flex items have purple border: */ 42 border: 2px dotted purple; 43 } 44 45 .flexbox > * > * { 46 /* Flex items' contents are gray & fixed-size: */ 47 background: gray; 48 width: 10px; 49 height: 80px; 50 } 51 </style> 52 </head> 53 <body> 54 <!-- Check for min-height:auto resolving correctly when the smallest 55 candidate value is: --> 56 <!-- *** (a) Used 'flex-basis' (from 'height') *** --> 57 <!-- First, without definite max-height: --> 58 <div class="flexbox"> 59 <div style="height: 50px"><div></div></div> 60 </div> 61 <!-- ...and now with definite (& large) 'max-height': --> 62 <div class="flexbox"> 63 <div style="height: 50px; max-height: 120px;"><div></div></div> 64 </div> 65 <!-- ...and now with used 'flex-basis' being a calc expression:--> 66 <div class="flexbox"> 67 <div style="height: calc(10% + 50px)"><div></div></div> 68 </div> 69 70 <!-- *** (b) The computed 'max-height' *** --> 71 <!-- First, with a larger candidate 'flex-basis' value (from 'height') --> 72 <div class="flexbox"> 73 <div style="height: 100px; max-height:50px"><div></div></div> 74 </div> 75 <!-- ...and now with a larger explicit 'flex-basis' value (which shouldn't 76 be considered for 'min-height:auto' anyway) --> 77 <div class="flexbox"> 78 <div style="flex-basis: 100px; max-height:50px"><div></div></div> 79 </div> 80 <!-- ...and now with a smaller explicit 'flex-basis' value (which shouldn't 81 be considered for 'min-height:auto' anyway) --> 82 <div class="flexbox"> 83 <div style="flex-basis: 10px; max-height:50px"><div></div></div> 84 </div> 85 86 <!-- *** (c) (no intrinsic aspect ratio) The min-content size *** --> 87 <!-- First, with a larger candidate 'flex-basis' value (from 'height') --> 88 <div class="flexbox"> 89 <div style="height: 100px"><div></div></div> 90 </div> 91 <!-- ...and now with a larger explicit 'flex-basis' value (which shouldn't 92 be considered for 'min-height:auto' anyway) --> 93 <div class="flexbox"> 94 <div style="flex-basis: 100px"><div></div></div> 95 </div> 96 <!-- ...and now with a smaller explicit 'flex-basis' value (which shouldn't 97 be considered for 'min-height:auto' anyway) --> 98 <div class="flexbox"> 99 <div style="flex-basis: 10px"><div></div></div> 100 </div> 101 </body> 102 </html>