简体   繁体   English

如何在同一个块中显示内联元素的Bootstrap网格视图?

[英]How to display Bootstrap grid view with elements inlined in the same block?

I am using bootstrap "list grid products view" sample and grid elements are displayed fine when description and picture height is the same. 我正在使用bootstrap“列表网格产品视图”样本,并且当描述和图片高度相同时,网格元素显示正常。

Working sample: https://codepen.io/ajaypatelaj/pen/zIBjJ 工作样本: https://codepen.io/ajaypatelaj/pen/zIBjJhttps://codepen.io/ajaypatelaj/pen/zIBjJ

Problem comes in when description, price and picture are of different height and do not display elements in line: 当描述,价格和图片具有不同的高度并且不显示元素时,问题就出现了:

https://codepen.io/getkitchendeal/pen/gRgGeG

i tried to fix with=> 我试着修复=>

display: inline-block;
vertical-align: top;

There is a way to fix this, but it's ugly. 有办法解决这个问题,但这很丑陋。 It's called the clearfix hack. 它被称为clearfix hack。 Check out this thread What does the clearfix class do in css? 看看这个线程clearfix类在css中做了什么?

What I would do here is fix min-height for each block for grid system. 我在这里要做的是为网格系统修复每个块的最小高度。

Create a new css rule: 创建一个新的css规则:

.list-group-item .thumbnail {
    min-height: inherit;
}

And add another one in .thumbnail 并在.thumbnail中添加另一个

.thumbnail {
    margin-bottom: 20px;
    padding: 0px;
    -webkit-border-radius: 0px;
    -moz-border-radius: 0px;
    border-radius: 0px;
    min-height: 400px; #new rule
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM