Flex-box 中的 Row Wrap 未在 Safari 中换行 [英] Row Wrap in flex-box not wrapping in Safari

查看:31
本文介绍了Flex-box 中的 Row Wrap 未在 Safari 中换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个 flex 容器有四个子元素,每个子元素的 flex-basis 为 25% 和 a min-width.flex-flow 设置为行换行.Safari 以外的浏览器会按预期处理此问题:如果达到最小宽度,它将下一项包装到下一行.在 Safari 中,它会溢出容器.

A flex container has four children, each with a flex-basis of 25% an a min-width. flex-flow is set to row wrap. Browsers other then Safari handle this as expected: if the min-width is reached, it wraps the the next item to the next row. In Safari it overflow the container.

在此处查看演示:http://codepen.io/lbilharz/pen/aJbkI

h1 Why this ain't wrappin' in mobile-safari?
  .flex
    for i in ['one','two','three','four']
      .item
        h2=i

手写笔

.flex
  display flex
  flex-wrap wrap
  flex-direction row
  padding 1em
  background lightyellow
  .item
    flex 1 0 25%
    padding 1em
    box-sizing border-box
    min-width 15em

有什么想法吗?

推荐答案

根据 对 bugs.webkit 的评论.org,看来解决方法很简单!

Per a comment on bugs.webkit.org, it seems the solution is simple!

如果你的风格是

div.flex {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-flex-direction: row;
    flex-direction: row;
}
div.flex .item {
    min-width: 15em;
    -webkit-flex: 1;
    flex: 1;
}

您只需要为您的 flex 声明添加更明确的内容.其实我觉得这样只需要改一行

you just need to add more explicitness to your flex declaration. In fact, I think only one line needs to change like so

div.flex {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-flex-direction: row;
    flex-direction: row;
}
div.flex .item {
    min-width: 15em;
    -webkit-flex: 1 1 15em; /* this */
    flex: 1;
} 

这篇关于Flex-box 中的 Row Wrap 未在 Safari 中换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆