我想从这里联系一个未定义数量的div(如在Pinterest中):
++++++++ ********
+ + * *
+ + * *
+ + ********
+ +
++++++++
~~~~~~~~ --------
~ ~ - -
~ ~ - -
~~~~~~~~ - -
- -
- -
- -
- -
--------
到此:
++++++++ ********
+ + * *
+ + * *
+ + ********
+ + --------
++++++++ - -
~~~~~~~~ - -
~ ~ - -
~ ~ - -
~~~~~~~~ - -
- -
- -
--------
是否可以使用CSS或其他东西?
答案 0 :(得分:3)
答案 1 :(得分:1)
由于zessx,我在zessx answer引用了这个答案。
<h2>Without columns</h2>
<div class="box">1 Lorem Ipsum</div>
<div class="box">2 Lorem Ipsum Lorem Ipsum</div>
<div class="box">3 Lorem Ipsum</div>
<p class="clear"> </p>
<div class="box">4 Lorem Ipsum Lorem</div>
<div class="box">5 Lorem Ipsum</div>
<div class="box">6 Lorem Ipsum</div>
<p class="clear"> </p>
<div class="box">7 Lorem Ipsum</div>
<div class="box">8 Lorem Ipsum</div>
<h2>With columns</h2>
<div class="column">
<div class="box">1 Lorem Ipsum</div>
<div class="box">4 Lorem Ipsum Lorem</div>
<div class="box">7 Lorem Ipsum</div>
</div>
<div class="column">
<div class="box">2 Lorem Ipsum Lorem Ipsum</div>
<div class="box">5 Lorem Ipsum</div>
<div class="box">8 Lorem Ipsum</div>
</div>
<div class="column">
<div class="box">3 Lorem Ipsum</div>
<div class="box">6 Lorem Ipsum</div>
</div>
CSS
.box {
width: 50px;
min-height: 50px;
background: #ccc;
margin: 3px;
padding: 3px;
float: left;
}
.clear {
clear: both;
height: 0px;
}
.column {
width:60px;
float: left;
}