我试图在引导程序中创建一个响应式网格,在页面上有四个产品(有四列)。我希望每个产品的盒子在整个页面上完美排列。当标题的文字行数不同时,我遇到了问题。可以看到下面的问题(注意我还没有添加第四个产品)。
这是我的HTML代码
<div class="container bg">
<!-- Three columns of text below the carousel -->
<div class="row">
{% for deal in deals %}
<div class="col-xs-12 col-sm-6 col-md-3 rwrapper">
<div class="rlisting">
<div class="col-md-12 nopad hover11">
<figure><img src="{{ deal.image.url }}" class="img-responsive" style="width:250px;height:250px;margin:20px"></figure>
</div>
<div class="col-md-12 nopad">
<h5>{{ deal.retailer}}</h5>
<h3>{{ deal.title}}</h3>
<h3><strong>{{deal.price}}</strong><h3>
<div class="rfooter">
<i class="fa fa-phone-square"></i><a href="{{deal.link}}" role="button" class="btn btn-success">See Deal</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
和CSS在这里:
.bg{background-color: #dfdfdf;}
.rwrapper{padding: 1px;}
.rlisting{background-color: #fff;overflow: hidden;}
.rlisting img{width: 100%}
.nopad{padding:0;}
.rfooter{width: 50%;}
.rlisting h5,.rlisting p{padding:0 15px; font-style:italic;}
.rlisting h3,.rlisting p{padding:0 15px;}
/* Opacity #1 */
.hover11 figure img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.hover11 figure:hover img {
opacity: .5;
}
.column {
margin: 15px 15px 0;
padding: 0;
}
.column:last-child {
padding-bottom: 60px;
}
.column::after {
content: '';
clear: both;
display: block;
}
.column div {
position: relative;
float: left;
width: 300px;
height: 200px;
margin: 0 0 0 25px;
padding: 0;
}
.column div:first-child {
margin-left: 0;
}
.column div span {
position: absolute;
bottom: -20px;
left: 0;
z-index: -1;
display: block;
width: 300px;
margin: 0;
padding: 0;
color: #444;
font-size: 18px;
text-decoration: none;
text-align: center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
opacity: 0;
}
figure {
margin: 0;
height: 250px;
width: 250px;
padding: 0;
background: #fff;
overflow: hidden;
}
figure:hover+span {
bottom: -36px;
opacity: 1;
}
.navbar {
margin-bottom:-1px;
border-radius:0;
}
#submenu {
background-color: #e7e7e7;
margin-bottom:20px;
min-height:0;
}
.navbar-nav{margin:0}
.collapsing {
display:none;
}
.jumbotron {
margin-top: 50px;
}
.nav-2{
position:fixed;
top:50px;
left:0px;
width:100%;
background:#fff;
padding-top:0px;
padding-bottom:0px;
}
.container-2{margin-top:120px}
答案 0 :(得分:0)
我会使用scss
而不是css
来简化这一过程,并将标题的高度设置为您想要显示的最大行数的倍数。
$line-height: 20px;
$line-count: 3; //Example of 3 lines
.title {
line-height: $line-height;
height: $line-count * $line-height;
}
然后,您还应将显示的文本长度限制为不超过3行的合理限制(如果需要,还可添加省略号)。
当然也可以使用css
并在此示例中将其设置为60px。