【发布时间】:2017-02-16 08:28:12
【问题描述】:
根据屏幕尺寸,我有几个小部件。这是我的布局:
<div class="col-xl-4 col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="widget">
<div class="name">
Block name
</div>
<div class="description">
Some description goes here
</div>
</div>
</div>
<div class="col-xl-4 col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="widget">
<div class="name">
Block name
</div>
<div class="description">
Some very long description goes here
</div>
</div>
</div>
<div class="col-xl-4 col-lg-3 col-md-4 col-sm-6 col-xs-12">
<div class="widget">
<div class="name">
Block name
</div>
<div class="description">
Some description goes here
</div>
</div>
</div>
样式如下:
.widget {
width: 100%;
margin: 10px;
padding: 10px;
background-color: white;
//height: auto;
height: 80px;
border: 1px silver solid;
font-size: 18px;
}
.name {
font-weight: bold;
height: 40px;
color: #082654;
}
.description {
color: #4AB6E1;
}
这里是jsfiddle
问题是我希望它们具有一定的高度:例如 80 像素,因为它的大小在几乎所有情况下看起来都不错,但很少我在小部件描述中有一些较长的内容,然后它就会开箱即用。所以在这种情况下,我希望它的高度适应内容大小,所有其他小部件也适应它的高度。当我将小部件高度设置为自动时 - 只有单个小部件在高度上拉伸并且它们看起来不均匀。任何想法如何更改样式以实现我的需要?
【问题讨论】:
-
如何使用
display:table-cell -
min-height: 80px; -
@dNitro,它只制作一个小部件来适应它的高度
标签: css twitter-bootstrap