6 background-color: pink;
7 outline:
1px solid black;
12 background-color: grey;
29 -webkit-writing-mode: horizontal-tb;
32 -webkit-writing-mode: horizontal-bt;
35 -webkit-writing-mode: vertical-rl;
38 -webkit-writing-mode: vertical-lr;
44 flex-flow: row-reverse;
50 flex-flow: column-reverse;
53 margin:
10px
20px
30px
40px;
56 margin:
13px auto
17px auto;
59 -webkit-margin-before:
10px;
60 -webkit-margin-after:
30px;
61 -webkit-margin-start:
40px;
62 -webkit-margin-end:
20px;
65 -webkit-margin-before: auto;
66 -webkit-margin-after:
17px;
67 -webkit-margin-start: auto;
68 -webkit-margin-end:
2px;
70 .flexbox
> :nth-child(
1) {
71 background-color: blue;
73 .flexbox
> :nth-child(
2) {
74 background-color: green;
76 .flexbox
> :nth-child(
3) {
77 background-color: red;
80 <script src=
"../../resources/check-layout.js"></script>
81 <body onload=
"checkLayout('.flexbox')">
84 function positionAsString(position
)
86 return 'data-offset-x="' + position
[0] + '" data-offset-y="' + position
[1] + '"';
89 function asString(expectations
)
91 return 'data-expected-width="' + expectations
[0] + '" data-expected-height="' + expectations
[1] + '" ' + positionAsString(expectations
.slice(2, 4));
94 var physicalContainerSize
= [160, 140];
95 var physicalFlexBoxPosition
= [40, 10];
97 var physicalExpectations
= {
100 container
: physicalContainerSize
,
101 flexbox
: physicalFlexBoxPosition
,
102 column
: [20, 20, 80, 23],
103 row
: [20, 20, 80, 23],
104 'column-reverse': [20, 20, 80, 73],
105 'row-reverse': [20, 20, 80, 23],
108 container
: physicalContainerSize
,
109 flexbox
: physicalFlexBoxPosition
,
110 column
: [20, 20, 80, 23],
111 row
: [20, 20, 80, 23],
112 'column-reverse': [20, 20, 80, 73],
113 'row-reverse': [20, 20, 80, 23],
118 container
: physicalContainerSize
,
119 flexbox
: physicalFlexBoxPosition
,
120 column
: [20, 20, 80, 73],
121 row
: [20, 20, 80, 73],
122 'column-reverse': [20, 20, 80, 23],
123 'row-reverse': [20, 20, 80, 73],
126 container
: physicalContainerSize
,
127 flexbox
: physicalFlexBoxPosition
,
128 column
: [20, 20, 80, 73],
129 row
: [20, 20, 80, 73],
130 'column-reverse': [20, 20, 80, 23],
131 'row-reverse': [20, 20, 80, 73],
136 container
: physicalContainerSize
,
137 flexbox
: physicalFlexBoxPosition
,
138 column
: [20, 20, 80, 73],
139 row
: [20, 20, 80, 73],
140 'column-reverse': [20, 20, 80, 73],
141 'row-reverse': [20, 20, 80, 23],
144 container
: physicalContainerSize
,
145 flexbox
: physicalFlexBoxPosition
,
146 column
: [20, 20, 80, 23],
147 row
: [20, 20, 80, 23],
148 'column-reverse': [20, 20, 80, 23],
149 'row-reverse': [20, 20, 80, 73],
154 container
: physicalContainerSize
,
155 flexbox
: physicalFlexBoxPosition
,
156 column
: [20, 20, 80, 73],
157 row
: [20, 20, 80, 73],
158 'column-reverse': [20, 20, 80, 73],
159 'row-reverse': [20, 20, 80, 23],
162 container
: physicalContainerSize
,
163 flexbox
: physicalFlexBoxPosition
,
164 column
: [20, 20, 80, 23],
165 row
: [20, 20, 80, 23],
166 'column-reverse': [20, 20, 80, 23],
167 'row-reverse': [20, 20, 80, 73],
172 var logicalExpectations
= {
175 container
: [160, 140],
177 column
: [20, 20, 22, 73],
178 row
: [20, 20, 22, 73],
179 'column-reverse': [20, 20, 22, 73],
180 'row-reverse': [20, 20, 22, 73],
183 container
: [160, 140],
185 column
: [20, 20, 118, 73],
186 row
: [20, 20, 118, 73],
187 'column-reverse': [20, 20, 118, 73],
188 'row-reverse': [20, 20, 118, 73],
193 container
: [160, 140],
195 column
: [20, 20, 22, 47],
196 row
: [20, 20, 22, 47],
197 'column-reverse': [20, 20, 22, 47],
198 'row-reverse': [20, 20, 22, 47],
201 container
: [160, 140],
203 column
: [20, 20, 118, 47],
204 row
: [20, 20, 118, 47],
205 'column-reverse': [20, 20, 118, 47],
206 'row-reverse': [20, 20, 118, 47],
211 container
: [140, 160],
213 column
: [20, 20, 73, 22],
214 row
: [20, 20, 73, 22],
215 'column-reverse': [20, 20, 73, 22],
216 'row-reverse': [20, 20, 73, 22],
219 container
: [140, 160],
221 column
: [20, 20, 73, 118],
222 row
: [20, 20, 73, 118],
223 'column-reverse': [20, 20, 73, 118],
224 'row-reverse': [20, 20, 73, 118],
229 container
: [140, 160],
231 column
: [20, 20, 47, 22],
232 row
: [20, 20, 47, 22],
233 'column-reverse': [20, 20, 47, 22],
234 'row-reverse': [20, 20, 47, 22],
237 container
: [140, 160],
239 column
: [20, 20, 47, 118],
240 row
: [20, 20, 47, 118],
241 'column-reverse': [20, 20, 47, 118],
242 'row-reverse': [20, 20, 47, 118],
247 var writingModes
= ['horizontal-tb', 'horizontal-bt', 'vertical-lr', 'vertical-rl'];
248 var flexFlows
= ['row', 'column', 'row-reverse', 'column-reverse'];
249 var directions
= ['ltr', 'rtl'];
250 var marginTypes
= ['physical', 'logical'];
252 marginTypes
.forEach(function(marginType
) {
253 writingModes
.forEach(function(writingMode
) {
254 flexFlows
.forEach(function(flexFlow
) {
255 directions
.forEach(function(direction
) {
256 var flexboxClassName
= writingMode
+ ' ' + direction
+ ' ' + flexFlow
+ ' ' + marginType
;
257 var title
= document
.createElement('div');
258 title
.className
= 'title';
259 title
.innerHTML
= flexboxClassName
;
260 document
.body
.appendChild(title
);
262 var expectations
= (marginType
== 'physical') ? physicalExpectations
: logicalExpectations
;
263 expectations
= expectations
[writingMode
][direction
];
264 var flexboxExpectations
= positionAsString(expectations
.flexbox
);
266 var flexItemExpectations
= asString(expectations
[flexFlow
]);
268 var container
= document
.createElement('div');
269 container
.className
= 'container';
270 container
.setAttribute('data-expected-width', expectations
.container
[0]);
271 container
.setAttribute('data-expected-height', expectations
.container
[1]);
273 container
.innerHTML
= '<div class="flexbox ' + flexboxClassName
+ '" ' + flexboxExpectations
+ '>\n' +
274 '<div style="height: 20px; width: 20px;" ' + flexItemExpectations
+ '></div>\n' +
277 document
.body
.appendChild(container
);