是否有响应式垂直显示:flex? (没有表格/没有 JS)

Is there a responsive vertical display: flex? (no tables / no JS)

假设我们有两个 div 包装器。请注意,每个包装器的宽度 and/or 高度都可以改变。这个包装内有几个 divdiv 的数量可以从 1 到 ~ 任意变化。

我想要水平视图和垂直视图。 为了获得均匀的水平分布,使用 css 属性 display: flex;

我想垂直实现同样的效果。 display: table; 非常接近我想要实现的目标。然而,对于表格,我们根本无法改变高度。

    +-----+-----+-----+            +-----------------+
    |     |     |     |            |                 |
    |     |     |     |            +-----------------+
    |     |     |     |            |                 |
    |     |     |     |            +-----------------+
    |     |     |     |            |                 |
    +-----+-----+-----+            +-----------------+
       display: flex;                 ??????: ????;

this pen 视为模板。

使用 flex-direction 更改弹性框的显示方式。
它可以采用的值:row | row-reverse | column | column-reverse。默认为行。

.flexible {
  display: flex;
  flex-direction: column;
}
<div class="flexible">
  <div>1</div>
  <div>2</div>
  <div>3</div>
</div>

查看 this guide 以帮助您使用 flexbox。

使用属性flex-direction: column,可以改变对齐方向。

我会推荐这个 web-site : http://flexbox.help/ 。它描述并允许测试 flexboxes 的所有 属性。

你用flex-wrap..

.wrapper-h {
  height: 100px;
  width: 100px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
}

http://codepen.io/anon/pen/zNVypq