0

我在 html 中有几个框

<div class="parent">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div>

用 css 定义

.box{
width : 200px;
height : 300px;
display :  block;
float : left
}

有没有办法在父级中提供日志文本并在子级中DIV流动文本?还是应该做?DIVCSSJavascript

当然,在哪里提供文本并不重要,我只想将多余的文本流到下一个框。

4

1 回答 1

5

将您的 HTML 更改为包含内容的单个元素,例如:

<div class="parent">
  <div class="box"></div>
</div>

然后添加这些样式规范:

.box {
   -moz-column-count: 3;
   -webkit-column-count: 3;
   column-count: 3;
   height: 10em; /* Or whatever height is appropriate. */
}

有关 CSS 列的更多信息,请参阅http://css-tricks.com/snippets/css/multiple-columns/https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_multi-column_layouts#The_columns_shorthand .

于 2012-12-12T19:30:00.210 回答