3 <link href=
"resources/flexbox.css" rel=
"stylesheet">
9 background-color: #aaa;
11 outline:
2px solid red;
20 .flexbox :nth-child(
1) {
21 background-color: blue;
23 .flexbox :nth-child(
2) {
24 background-color: green;
33 -webkit-writing-mode: horizontal-tb;
36 -webkit-writing-mode: horizontal-bt;
39 -webkit-writing-mode: vertical-rl;
42 -webkit-writing-mode: vertical-lr;
46 if (window
.testRunner
)
47 testRunner
.dumpAsText();
49 <script src=
"../../resources/js-test.js"></script>
52 var writingModes
= ['horizontal-tb', 'horizontal-bt', 'vertical-lr', 'vertical-rl'];
53 var flexFlows
= ['row', 'column', 'row-reverse', 'column-reverse'];
54 var directions
= ['ltr', 'rtl'];
56 writingModes
.forEach(function(writingMode
) {
57 flexFlows
.forEach(function(flexFlow
) {
58 directions
.forEach(function(direction
) {
59 var flexboxClassName
= writingMode
+ ' ' + direction
+ ' ' + flexFlow
;
61 var title
= document
.createElement('div');
62 title
.className
= 'title';
63 title
.innerHTML
= flexboxClassName
;
64 document
.body
.appendChild(title
);
66 var isColumn
= flexFlow
.indexOf('column') != -1;
67 var isHorizontalFlow
= (writingMode
.indexOf('horizontal') != -1) ? !isColumn
: isColumn
;
69 var container
= document
.createElement('div');
70 container
.innerHTML
= '<div class="flexbox ' + flexboxClassName
+ '" style="align-items: baseline;">' +
71 '<div><div style="display:inline-block;"></div></div>' +
72 '<div style="margin-top:20px;"><div style="display:inline-block;"></div></div>' +
75 container
.firstChild
.isHorizontal
= writingMode
.indexOf('horizontal') != -1;
76 container
.firstChild
.isHorizontalFlow
= isHorizontalFlow
;
77 container
.firstChild
.isColumn
= isColumn
;
78 container
.firstChild
.isLTR
= direction
== 'ltr';
79 document
.body
.appendChild(container
);
84 // Sanity check that the align-items:baseline flex items align to the same cross-axis position.
85 var flexboxen
= document
.getElementsByClassName('flexbox');
86 for (var i
= 0, len
= flexboxen
.length
; i
< len
; i
++) {
87 var flexbox
= flexboxen
[i
];
88 firstChild
= flexbox
.firstChild
;
89 lastChild
= flexbox
.lastChild
;
90 if (!flexbox
.isHorizontal
&& flexbox
.isColumn
&& flexbox
.isLTR
) {
91 shouldBe('firstChild.offsetTop', "0");
92 shouldBe('lastChild.offsetTop', "20");
93 } else if (flexbox
.isHorizontalFlow
)
94 shouldBe('firstChild.offsetTop', 'lastChild.offsetTop');
96 shouldBe('firstChild.offsetLeft', 'lastChild.offsetLeft');