2013-02-21 78 views
2

对不起,如果我的英语有错误))。我的问题是如何使高度限制div?我的意思是,我的div有一些ul块,例如:如何让高度限制div?

<div> 
<ul> 
    <li>First text</li> 
</ul> 
</div> 

而我的DIV有高度280像素。当我尝试添加越来越多<li>smth...</li> - 它越来越低,并且毕竟我的文字低于我的div的高度限制。

不要提出float:left,这意味着,我的所有文本都会在水平线上添加,但是我想实现垂直高度限制。你知道,像报纸一样。

逻辑:我的文字必须在我的身高限制之前越​​来越低,在此之后,我的文字必须自行拆分,然后继续在新的垂直线上向下移动到同一个div元素中。

图片对于那些谁不明白我在说什么:

Image

+3

你看过http://stackoverflow.com/questions/4923/wrapping-lists-into-columns? – Raad 2013-02-21 12:30:42

+0

@你是对的目标 – entonio 2013-02-21 12:43:02

+0

@entonio - 谢谢。我不害羞 - 我会随时采取upvote;) – Raad 2013-02-21 12:54:12

回答

1

我不知道是否有可能这个脚本中包含的宽度,但它将使从柱流柱。我也注意到,这似乎并没有在IE浏览器中工作。

<head> 
<style> 
.columnFlow 
{ 
-moz-column-count:3; /* Firefox */ 
-webkit-column-count:3; /* Safari and Chrome */ 
column-count:3; 

-moz-column-gap:40px; /* Firefox */ 
-webkit-column-gap:40px; /* Safari and Chrome */ 
column-gap:40px; 

-moz-column-rule:2px outset #ff00ff; /* Firefox */ 
-webkit-column-rule:4px outset #ff00ff; /* Safari and Chrome */ 
column-rule:4px outset #ff00ff; 
} 
</style> 
</head> 
<body> 

<div class="columnFlow"> 
This text will flow within 3 different columns. The only think that I am unsure about is how to get this to work within IE. Also I am not sure how to specifically set the width. It appears as though it even spreads the provided text evenly within the amount of columns that the developer chooses. I hope this helps. 
</div> 

</body> 

在W3C网站上有一些额外的版本。我希望这有帮助! http://www.w3schools.com/css3/css3_multiple_columns.asp