html - CSS: Full width flex column doesn't stack on top of each other on webkit -
i have 2 divs in container this:
<div class="container"> <div class="div-a"> hello </div> <div class="div-b"> lorem </div> </div> and have set container display:flex , flex-direction column.
i aim align 2 divs on top of each other. works fine on firefox not on webkit (chrome/safari). on webkit, columns align next each other instead.
here jsfiddle can see.
my css is:
.container { width:100%; float:left; flex-direction: column; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; } .div-a { background:lightgreen; order:2; width:100%; float:left; } .div-b { background:lightblue; order:1; width:100%; float:left; } why not working on webkit?
in order flex work across browsers (especially safari desktop , ios ), need prefix related properties. visit here browser support details.
example of flex-direction: column;
.container { display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; } .a { background: lightgreen; -ms-flex-order: 2; -webkit-order: 2; order: 2; } .b { background: lightblue; -ms-flex-order: 1; -webkit-order: 1; order: 1; } <div class="container"> <div class="a">a</div> <div class="b">b</div> </div> example of flex-direction: row;
.container { display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-direction: row; -webkit-flex-direction: row; flex-direction: row; } .a, .b { -ms-flex: 1; -webkit-flex: 1; flex: 1; } .a { background: lightgreen; -ms-flex-order: 2; -webkit-order: 2; order: 2; } .b { background: lightblue; -ms-flex-order: 1; -webkit-order: 1; order: 1; } <div class="container"> <div class="a">a</div> <div class="b">b</div> </div>
Comments
Post a Comment