[英]Equalizing boxes with same space vertically but different Height
我需要用可变的高度来均衡列表项的顶部。 我也希望每个盒子之间都具有相同的空间,如下图所示:
以下是我的代码:
HTML:
<div class="wrapper">
<ul class="content">
<li class="item">1 test test test test test test</li>
<li class="item">2 test test test test test test test test test</li>
<li class="item">3 test test test test test test test test test test test test</li>
<li class="item">4 test test test test test test</li>
<li class="item">5 test test test test test test test test test test test test test test test</li>
</ul>
</div>
CSS:
.wrapper {
padding: 0px
}
.content {
width:100%;
}
.item {
background:blue;
color:white;
padding:30px;
width:100px;
list-style:none;
display:inline-block;
top:0;
}
这是我的小提琴需要您的帮助来解决。
你想做这个吗? http://jsfiddle.net/BuaC3/
.wrapper{padding:0}
.content{width:100%;}
.item{background:blue; margin:0 5px 5px;float:right; color:white; padding:30px; width:100px; list-style:none; display:inline-block;top:0; }
如果我理解正确,请申请
vertical-align:top;
对于.item
。
( top
对静态放置的元素没有影响 )
更新 :
如果要使框之间的垂直空间相等,则可以按如下方式使用css3 flex框 ( 尽管框的顺序会有所不同 ):
.content {
display:flex;
flex-flow: column wrap;
width:100%;
max-height:100%;
}
如果您想完全按照图片中所示的顺序进行订购,那么您可能需要依靠砌体之类的插件
请检查这个小提琴
在.item
类中添加了以下规则。
.item{
vertical-align: top; /* alignment */
margin-top: 10px /* breathing space */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.