flexbox和wrap属性 [英] flexbox and wrap property

查看:175
本文介绍了flexbox和wrap属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发和应用程序与phonegap。我想使用flexbox来布局我的主要应用程序区域中的一些按钮。

I am developing and app with phonegap. I wanted to use the flexbox to layout some buttons in my main application area.

有人可以解释为什么 http://jsfiddle.net/apYLB/ 不会在最新Chrome中包装元素?

Can somebody explain why this http://jsfiddle.net/apYLB/ doesn't wrap elements in latest chrome?

HTML:

<div class="flex-container">
    <div class="flex-item">1</div>
    <div class="flex-item">2</div>
    <div class="flex-item">3</div>
    <div class="flex-item">4</div>
    <div class="flex-item">5</div>
    <div class="flex-item">6</div>
</div>

CSS:

.flex-container {
    display: -webkit-box;
    display: flex;
    flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    -webkit-flex-direction: row;
    -webkit-flex-flow: row wrap;
    flex-flow: row wrap;
    -webkit-box-align: end;
    -moz-box-align: end;
    box-align: end;
    -webkit-box-pack: center;
    -moz-box-pack: center;
    box-pack: center;
    justify-content:space-around;
    height:100%;
}
.flex-item {
    margin:0 10px 25px 0;
    width:86px;
    border:1px solid #000;
}
.flex-item img {
    max-height:80px;
}

它们水平放置,只有三个半框出现。 >

They are laid horizzontally and only 3 and a half boxes appear.

推荐答案

你有很多不太对的地方。首先,你将旧的属性与新的属性混合( display:-webkit-box 来自2009年草案,但 -webkit-flex-

You have quite a few things not quite right here. First, you're mixing old properties with new properties (display: -webkit-box is from the 2009 draft, but -webkit-flex-flow is from the standard draft).

其次,2009年的Flexbox实现都没有支持 box-lines:multiple ,这是启用包装所必需的。可悲的是,几乎所有的移动设备都只支持2009年的草案。支持现代规范的Firefox版本目前不支持封装(flex-flow和flex-wrap是支持的属性,但不支持与包装相关的值)。

Second, none of the 2009 Flexbox implementations support box-lines: multiple, which is required for enabling wrapping. Sadly, nearly all mobile devices support only the 2009 draft. Firefox versions that support the modern specification currently do not support wrapping either (flex-flow and flex-wrap are supported properties, but the values pertaining to wrapping are not supported).

第三,你有 justify-content:space-around ,但2009年的对应版本设置为 box-pack:center 。中心在所有草稿中居中。

Third, you've got justify-content: space-around, but its 2009 counterpart is set to box-pack: center. Center is center in all drafts.

http:// cssdeck .com / labs / ccamtvl5

.flex-container {
  display: -ms-flexbox;
  display: -webkit-flex;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -ms-flex-line-pack: end;
  -webkit-align-content: flex-end;
  align-content: flex-end;
  -ms-flex-pack: distribute;
  -webkit-justify-content: space-around;
  justify-content: space-around;
  height: 100%;
}
@supports (flex-wrap: wrap) { /* hide from incomplete Firefox versions */
  .flex-container {
    display: flex;
  }
}

更新可以在Firefox中使用版本28,但只有在使用现代属性(而不是旧的前缀,如 display:-moz-box )。

Update: Wrapping now works in Firefox as of version 28, but only when using the modern properties (not the old prefixed ones like display: -moz-box).

这篇关于flexbox和wrap属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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