flexbox-basic-textarea-vert-001.xhtml (3619B)
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 test checks that textarea elements behave correctly as flex items. 8 --> 9 <html xmlns="http://www.w3.org/1999/xhtml"> 10 <head> 11 <title>CSS Test: Testing flexbox layout algorithm property on textarea flex items in a vertical flex container</title> 12 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> 13 <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#layout-algorithm"/> 14 <link rel="match" href="flexbox-basic-textarea-vert-001-ref.xhtml"/> 15 <style> 16 div.flexbox { 17 height: 200px; 18 background: lightgreen; 19 display: flex; 20 justify-content: space-between; 21 flex-direction: column; 22 float: left; 23 margin-right: 10px; 24 font: 8px monospace; 25 } 26 textarea { 27 width: 20px; 28 height: 10px; 29 min-height: 0; 30 background: white; 31 border-radius: 0; 32 border: 1px dotted green; 33 margin: 0; 34 padding: 0; 35 } 36 </style> 37 </head> 38 <body> 39 40 <!-- A) One flex item --> 41 <div class="flexbox"> 42 <textarea/> 43 </div> 44 45 <!-- B) Text and a textarea (ensure they aren't merged into one flex item) 46 --> 47 <div class="flexbox"> 48 a b <textarea/> 49 </div> 50 51 <!-- C) Two textarea elements, getting stretched by different ratios, 52 from 0. 53 54 Space-to-be-distributed = 200px - borders = 200 - (1 + 1) - (1 + 1) 55 = 196px 56 57 1st element gets 5/9 of space: 5/9 * 196px = 108.8px 58 1st element gets 4/9 of space: 4/9 * 196px = 87.1px 59 --> 60 <div class="flexbox"> 61 <textarea style="flex: 5"/> 62 <textarea style="flex: 4"/> 63 </div> 64 65 <!-- D) Two textarea elements, getting stretched by different ratios, from 66 different flex bases. 67 68 Space-to-be-distributed = 200px - (33 + 1 + 1) - (13 + 1 + 1) = 150px 69 1st element gets 2/5 of space: 33px + 2/5 * 150px = 93px 70 1st element gets 3/5 of space: 13px + 3/5 * 150px = 103px 71 --> 72 <div class="flexbox"> 73 <textarea style="height: 33px; flex: 2 auto"/> 74 <textarea style="height: 13px; flex: 3 auto"/> 75 </div> 76 77 <!-- E) Two flex items, getting shrunk by different amounts. 78 79 Space-to-be-distributed = 200px - (150 + 1 + 1) - (100 + 1 + 1) = -54px 80 First element scaled flex ratio = 4 * 150 = 600 81 Second element scaled flex ratio = 3 * 100 = 300 82 * So, total flexibility is 600 + 300 = 900 83 84 1st element gets 600/900 of space: 150 + 600/900 * -54 = 114px 85 2nd element gets 300/900 of space: 100 + 300/900 * -54 = 82px 86 --> 87 <div class="flexbox"> 88 <textarea style="height: 150px; flex: 1 4 auto"/> 89 <textarea style="height: 100px; flex: 1 3 auto"/> 90 </div> 91 92 <!-- F) Making sure we don't grow past max-height --> 93 <!-- Same as (D), except we've added a max-height on the second element. 94 --> 95 <div class="flexbox"> 96 <textarea style="height: 33px; flex: 2 auto"/> 97 <textarea 98 style="height: 13px; max-height: 90px; flex: 3 auto"/> 99 </div> 100 101 <!-- G) Making sure we grow at least as large as min-height --> 102 <!-- Same as (C), except we've added a min-height on the second element. 103 --> 104 <div class="flexbox"> 105 <textarea style="height: 33px; flex: 2 auto"/> 106 <textarea 107 style="height: 13px; min-height: 150px; flex: 3 auto"/> 108 </div> 109 110 </body> 111 </html>