flexbox:在Safari中垂直分配元素

时间:2016-07-14 11:27:11

标签: css css3 flexbox

我需要在移动纵向视图中分发三个项目。使用flex并且它适用于除safari之外的所有其他浏览器。所以它不适用于iphone。

我一直使用align-content: space-between;flex-flow: row wrap;来进行对齐。在Safari中使用哪些正确的属性?

-> Here is the fiddle

*{
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
html, body{
  height: 100%;
  margin: 0;
}
.wrap{
  display: -webkit-box;display: -ms-flexbox;display: flex;
  -webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;
  -ms-flex-line-pack: justify;align-content: space-between;
  width: 100%;
  border: 1px solid red;
  height: 100%;
  
  -webkit-flex-flow: row wrap;
   flex-flow: row wrap;

}
div[class*="col"]{
  height: 50px;
  width: 100%;
  border: 1px solid green;
}
<div class="wrap">
  <div class="col1">

  </div>
  <div class="col1">

  </div>
  <div class="col1">

  </div>
</div>

1 个答案:

答案 0 :(得分:1)

您的代码缺少旧版Safari的必要-webkit-前缀:

display: -webkit-flex;
display: flex;

-webkit-flex-direction: column;
flex-direction: column;

-webkit-align-content: space-between;
align-content: space-between;

-webkit-flex-flow: row wrap;
flex-flow: row wrap;

参考文献: