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