0

我想创建以下方案中解释的行为:

每次元素在屏幕之外时,我都希望将其放在右侧的新列中。

在此处输入图像描述

目前,所有元素都在同一列中。

这是我的元素当前的显示方式:

  <style is="custom-style" include="iron-flex">
    .flex-wrap {
      @apply(--layout-wrap);
      @apply(--layout-vertical);
    }
  </style>
  <template>
    <div class="container flex-wrap" >
      <template is="dom-repeat" items="{{employeesArray}}">
          <employee-element name="{{item.title}}"
                           preview="{{item.preview}}"
                           width={{item.width}} height={{item.height}}>
          </employee-element>
      </template>
    </div>
  </template>

如何强制将元素放置在我绘制的位置?

4

1 回答 1

1

可以使用大多数较新的浏览器支持的 colomn 属性来完成:

.container {
    height: 100px;
    border: 1px solid black;
    column-fill: auto;
    -webkit-column-fill: auto;
    -moz-column-fill: auto;
    column-width: 150px;
    -webkit-column-width: 150px;
    -moz-column-width: 150px;
}

HTML:

<div class="container">
 <div>employee #1</div>
 <div>employee #2</div>
....
 <div>employee #x</div>
</div>

看到这个jsfiddle。更多关于 CSS 中的列属性可以在这里找到。

于 2016-04-24T13:47:06.867 回答