ios - Flexbox 在 iOS 上没有正确包装

标签 ios css flexbox

我有这个 CSS:CodePen

    * {
        margin:0;
        padding:0;
        box-sizing:border-box;          
    }
    body,html {
        width:100%; height: 100%;
    }

    .v-field, .v-field-label {
      border: 1px #bcbcbc solid;
      border-radius: 4px;
    }

    .vc-min-200 {
      min-width: 300px;
    }
    .vc-6 {
        width:50%;
    }

    .panel{ 
        border:1px #ccc solid;
    }
    .row {
        outline: 1px #c00 solid;
    }

    form.v-form {
      margin-top: 10px;
    }
    form.v-form .row.flex {
      margin: 15px 0px;
      display: flex;
      flex-wrap:wrap;
    }
    form.v-form .row.flex > div {
      margin: 10px 0px;
      padding: 0px 5px;
      flex: 1 1 auto;
      /*flex: 1 1 200px;*/
    }
    form.v-form .v-field, form.v-form .v-field-label {
      width: 100%;
      padding: 6px 12px;
    }

这个想法是让一个表单最多有 2 列,每列宽度为 50%,但是当窗口的大小调整到低于最小宽度时,它应该换成一个列。

它在桌面版 Chrome 和 Android 上运行良好,但在 iOS (10.0.2) 上无法正确包装。我附上了截图。 如果我取消注释 flex: 1 1 200px 行,那么它在 iOS 上运行良好,但在窗口大小允许时在桌面上生成 3 列,这不是我想要的。是否有适用于桌面和 iOS 的解决方案?

iOS fail screenshot

最佳答案

我认为您的问题与 this Safari bug 有关,其中以 px 而非百分比为单位时忽略 flex basis。你能试试百分比让我知道吗?如果我对 flex 的理解是正确的: 1 1 50%;你得到了想要的效果。

form.v-form .row.flex > div {
  margin: 10px 0px;
  padding: 0px 5px;
  flex: 1 1 50%;
}

here

关于ios - Flexbox 在 iOS 上没有正确包装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40007414/

相关文章:

ios - 如何在 iOS 自定义键盘中显示 google admob?

javascript - 图像以窗口为中心

html - CSS 动画 : squares loader

html - 侧边栏使用 Flexbox : contained links not spreading out properly

html - 给同级元素 "padding"作为 flexbox 属性 justify-content : space-around

ios - MVVM 架构使用 swift 获取数据和更新 UITableView

iphone - Objective-C中什么样的方法或操作会相对多使用一点CPU

css - 尝试排列 Twitter、Pinterest 和 Facebook 按钮

html - 如何垂直对齐固定高度的div中的元素?

ios - Node js socket io聊天发送消息通知