|
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 <!-- Testcase with percent-valued padding and/or margin on flex items. The spec |
|
7 says that percentage values on padding/margin-top and -bottom should be |
|
8 resolved against the flex container's height (not its width, as would |
|
9 be the case in a block). |
|
10 --> |
|
11 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
12 <head> |
|
13 <title>CSS Test: Testing percent-valued padding and margin on flex items</title> |
|
14 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> |
|
15 <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#layout-algorithm"/> |
|
16 <link rel="match" href="flexbox-mbp-horiz-4-ref.xhtml"/> |
|
17 <style> |
|
18 div { border: 0; } |
|
19 div.flexbox { |
|
20 width: 200px; |
|
21 display: flex; |
|
22 margin-bottom: 2px; |
|
23 border: 1px dotted black; |
|
24 } |
|
25 div.height50 { height: 50px; } |
|
26 |
|
27 .marginA { margin: 10% 8% 6% 4%; } |
|
28 .marginB { margin: 8% 10% 12% 14%; } |
|
29 .paddingA { padding: 8% 6% 4% 2%; } |
|
30 .paddingB { padding: 6% 8% 10% 12%; } |
|
31 |
|
32 div.child1 { |
|
33 flex: none; |
|
34 width: 10px; |
|
35 height: 10px; |
|
36 background: lightgreen; |
|
37 } |
|
38 div.child2 { |
|
39 flex: none; |
|
40 width: 10px; |
|
41 height: 10px; |
|
42 background: purple; |
|
43 } |
|
44 |
|
45 div.filler { |
|
46 /* Filler-div to fill up content-box and make padding easier to see. */ |
|
47 height: 10px; |
|
48 width: 100%; |
|
49 background: lightgrey; |
|
50 } |
|
51 |
|
52 </style> |
|
53 </head> |
|
54 <body> |
|
55 <!-- Flex container is auto-height - vertical margin and padding should |
|
56 resolve to 0, since they don't have anything to resolve % against. --> |
|
57 <div class="flexbox" |
|
58 ><div class="child1 paddingA"><div class="filler"/></div |
|
59 ><div class="child2 paddingB"><div class="filler"/></div |
|
60 ><div class="child1 marginA"></div |
|
61 ><div class="child2 marginB"></div |
|
62 ></div> |
|
63 |
|
64 <!-- Flex container has height: 50px - vertical margin and padding should |
|
65 resolve % values against that. --> |
|
66 <div class="flexbox height50" |
|
67 ><div class="child1 paddingA"><div class="filler"/></div |
|
68 ><div class="child2 paddingB"><div class="filler"/></div |
|
69 ><div class="child1 marginA"></div |
|
70 ><div class="child2 marginB"></div |
|
71 ></div> |
|
72 |
|
73 <!-- ...and now with align-items: flex-end, so we can see the margin-bottom |
|
74 in action --> |
|
75 <div class="flexbox height50" style="align-items: flex-end" |
|
76 ><div class="child1 paddingA"><div class="filler"/></div |
|
77 ><div class="child2 paddingB"><div class="filler"/></div |
|
78 ><div class="child1 marginA"></div |
|
79 ><div class="child2 marginB"></div |
|
80 ></div> |
|
81 |
|
82 <!-- ...and finally, with margin and padding applied to the same items --> |
|
83 <div class="flexbox height50" |
|
84 ><div class="child1 paddingA marginA"><div class="filler"/></div |
|
85 ><div class="child2 paddingB marginB"><div class="filler"/></div |
|
86 ></div> |
|
87 </body> |
|
88 </html> |