天天看点

flex弹性布局兼容写法

今天在写h5活动的时候,使用到了flex布局,在chrome浏览器手机模式下测试一切ok,然后使用真机(iphone 5c)时,就发现了各种问题?

在网上找了下flex布局的各种兼容写法,特此记录下

原文地址:弹性布局各种坑爹兼容

display:flex的兼容写法

display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -weblit-flex;
display: flex;
           

定义子元素换行flex-firection的兼容性写法

-webkit-box-orient: verical;
-webkit-box-direction: normal;
-moz-box-orient: verical;
-moz-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;

用box-orient:horizontal+box-direction:normal/reverse可以达到flex-direction:row/row-reverse效果
用box-orient:vertical+box-direction:normal/reverse可以达到flex-direction:column/column-reverse效果
           

定义子元素换行flex-wrap的兼容性写法

-webkit-flex-wrap: wrap;
-webkit-box-lines: multiple;
-moz-flex-wrap: wrap;
flex-wrap: wrap;
           

flex-flow: flex-direction flex-wrap的兼容写法

-webkit-flex-flow: row wrap;
-webkit-box-orient: horizontal;
-webkit-box-lines: multiple;
-moz-flex-flow: row wrap;
box-orient: horizontal;
box-lines: multiple;
flex-flow: row wrap;
           

横向排列布局justify-content的兼容写法

-webkit-justify-content: center;
justify-content: center;
-moz-box-pack: center;
-webkit-box-pack: center;
box-pack: center;
           

竖向排列布局align-items的兼容写法

-webkit-align-items: center;
align-items: center;
-webkit-box-align: center;
-moz-box-align: center;
box-align: center;
           

伸缩盒子布局的兼容写法

-webkit-box-flex: num;
-moz-box-flex: num;
box-flex: num;
-webkit-flex: num;
flex: num;