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