简体   繁体   English

如何使用CSS将文本从一个框流到另一个框

[英]How to flow text from a box to another with CSS

I have several boxes in html as 我在html中有几个框

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

defined with css 用CSS定义

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

Is there a way to provide a log text in the parent DIV and flow the text within child DIV s with CSS ? 有没有一种方法可以在父DIV提供日志文本,并使用CSS在子DIV传递文本? or it should be done with Javascript ? 还是应该用Javascript完成?

Of course, it does not matter where to provide the text, I just want to flow the excess text to the next box. 当然,在哪里提供文本都没有关系,我只想将多余的文本传递到下一个框。

Change your HTML to be a single element containing the content, such as: 将您的HTML更改为包含内容的单个元素,例如:

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

And then add these style specifications: 然后添加以下样式规范:

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

For more information on CSS Columns, see http://css-tricks.com/snippets/css/multiple-columns/ or https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_multi-column_layouts#The_columns_shorthand . 有关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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM