flexbox-sizing-vert-001.xhtml (3358B)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <!-- 7 This testcase checks how "min-height" and "max-height" affect the sizing 8 of vertical flex containers that have no explicit "height" property. 9 --> 10 <html xmlns="http://www.w3.org/1999/xhtml"> 11 <head> 12 <title>CSS Test: Testing sizing of an auto-sized vertical flex container with min-height and max-height constraints</title> 13 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> 14 <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#layout-algorithm"/> 15 <link rel="match" href="flexbox-sizing-vert-001-ref.xhtml"/> 16 <style> 17 div { width: 10px; } 18 div.flexbox { 19 float: left; 20 border: 1px dashed blue; 21 font-size: 10px; 22 display: flex; 23 flex-direction: column; 24 margin-right: 2px; 25 } 26 div.a { 27 flex: 1 20px; 28 max-height: 60px; 29 background: lightgreen; 30 } 31 div.b { 32 flex: 1 20px; 33 min-height: 40px; 34 max-height: 60px; 35 background: purple; 36 } 37 div.c { 38 flex: 1 40px; 39 min-height: 10px; 40 max-height: 60px; 41 background: orange; 42 } 43 </style> 44 </head> 45 <body> 46 <!-- floated auto-sized vertical flexbox should shrinkwrap its flex items' 47 hypothetical main sizes (their flex base sizes, clamped to min/max) --> 48 <div class="flexbox"> 49 <div class="a"/><div class="b"/><div class="c"/> 50 </div> 51 52 <!-- Adding a small min-size shouldn't affect that. --> 53 <div class="flexbox" style="min-height: 10px"> 54 <div class="a"/><div class="b"/><div class="c"/> 55 </div> 56 57 <!-- ...nor should a large max-size. --> 58 <div class="flexbox" style="max-height: 300px"> 59 <div class="a"/><div class="b"/><div class="c"/> 60 </div> 61 62 <!-- OK. Now, if we set a minimum size that's larger than the shrinkwrap 63 size, we should jump up to that size.--> 64 <div class="flexbox" style="min-height: 120px"> 65 <div class="a"/><div class="b"/><div class="c"/> 66 </div> 67 68 <!-- ...even if it's large enough that our items won't occupy all the 69 space. --> 70 <div class="flexbox" style="min-height: 200px"> 71 <div class="a"/><div class="b"/><div class="c"/> 72 </div> 73 74 <!-- If we set a maximum size that's smaller than the shrinkwrap size, 75 we should max out at that size.--> 76 <div class="flexbox" style="max-height: 70px"> 77 <div class="a"/><div class="b"/><div class="c"/> 78 </div> 79 80 <!-- The max-size may be small enough that our items will overflow. --> 81 <div class="flexbox" style="max-height: 20px"> 82 <div class="a"/><div class="b"/><div class="c"/> 83 </div> 84 85 <!-- But if we add a min-size, it beats the max-size. Here, we use a 86 min-size smaller than the sum of the items' base sizes... --> 87 <div class="flexbox" style="min-height: 58px; max-height: 20px"> 88 <div class="a"/><div class="b"/><div class="c"/> 89 </div> 90 91 <!-- ...and here we use a min-size larger than the sum of the items' 92 base sizes. --> 93 <div class="flexbox" style="min-height: 140px; max-height: 20px"> 94 <div class="a"/><div class="b"/><div class="c"/> 95 </div> 96 97 </body> 98 </html>