14 background-color: #aaa;
23 -webkit-writing-mode: horizontal-tb;
26 -webkit-writing-mode: horizontal-bt;
29 -webkit-writing-mode: vertical-rl;
32 -webkit-writing-mode: vertical-lr;
39 flex-flow: row-reverse;
45 flex-flow: column-reverse;
48 .flexbox :nth-child(
1) {
49 background-color: blue;
51 .flexbox :nth-child(
2) {
52 background-color: green;
62 .justify-content-flex-start {
63 justify-content: flex-start;
65 .justify-content-flex-end {
66 justify-content: flex-end;
68 .justify-content-center {
69 justify-content: center;
71 .justify-content-space-between {
72 justify-content: space-between;
74 .justify-content-space-around {
75 justify-content: space-around;
78 <script src=
"../../resources/check-layout.js"></script>
79 <body onload=
"checkLayout('.flexbox')">
828 var writingModes
= ['horizontal-tb', 'horizontal-bt', 'vertical-rl', 'vertical-lr'];
829 var flexDirections
= ['row', 'column', 'row-reverse', 'column-reverse'];
830 var directions
= ['ltr', 'rtl'];
831 var justifyContents
= ['flex-start', 'flex-end', 'center', 'space-between', 'space-around'];
833 function mainAxisDirection(writingMode
, flexDirection
)
835 if ((writingMode
.indexOf('horizontal') != -1 && flexDirection
.indexOf('row') != -1)
836 || (writingMode
.indexOf('vertical') != -1 && flexDirection
.indexOf('column') != -1))
841 function addChild(flexbox
, mainAxis
, crossAxis
, mainAxisLength
, crossAxisLength
, expectations
)
843 var child
= document
.createElement('div');
844 child
.setAttribute('style', mainAxis
+ ': ' + mainAxisLength
+ 'px;'
845 + crossAxis
+ ': ' + crossAxisLength
+ 'px; position: absolute;');
847 child
.setAttribute("data-expected-" + mainAxis
, mainAxisLength
);
848 child
.setAttribute("data-expected-" + crossAxis
, crossAxisLength
);
849 child
.setAttribute("data-offset-x", expectations
[0]);
850 child
.setAttribute("data-offset-y", expectations
[1]);
852 flexbox
.appendChild(child
);
855 writingModes
.forEach(function(writingMode
) {
856 flexDirections
.forEach(function(flexDirection
) {
857 directions
.forEach(function(direction
) {
858 justifyContents
.forEach(function(justifyContent
) {
859 var flexboxClassName
= writingMode
+ ' ' + direction
+ ' ' + flexDirection
+ ' justify-content-' + justifyContent
;
860 var title
= document
.createElement('div');
861 title
.className
= 'title';
862 title
.innerHTML
= flexboxClassName
;
863 document
.body
.appendChild(title
);
865 var mainAxis
= mainAxisDirection(writingMode
, flexDirection
);
866 var crossAxis
= (mainAxis
== 'width') ? 'height' : 'width';
868 var flexbox
= document
.createElement('div');
869 flexbox
.className
= 'flexbox ' + flexboxClassName
;
870 flexbox
.setAttribute('style', mainAxis
+ ': 80px;' + crossAxis
+ ': 20px');
872 var baselineMargin
= (flexDirection
.indexOf('row') != -1) ? '-webkit-margin-before: 5px' : '-webkit-margin-start: 5px';
874 var testExpectations
= expectations
[writingMode
][flexDirection
][direction
][justifyContent
];
875 addChild(flexbox
, mainAxis
, crossAxis
, 40, 10, testExpectations
['child1']);
876 addChild(flexbox
, mainAxis
, crossAxis
, 10, 20, testExpectations
['child2']);
878 document
.body
.appendChild(flexbox
);