简体   繁体   English

带有堆叠图像的Bootstrap列:需要具有相同的列高

[英]Bootstrap columns with stacked images: need to have same column height

I have a Bootstrap section with stacked images and the issue is that I want the second and third columns to always have the same height as the first column. 我有一个带有堆叠图像的Bootstrap部分,问题是我希望第二列和第三列始终与第一列具有相同的高度。 I can't seem to find a solution for the second and third column because they keep fluctuating in height as I change to different view sizes. 我似乎找不到第二和第三列的解决方案,因为当我改变到不同的视图大小时,它们保持高度波动。 It would be ideal to have them always align to the bottom and top. 让它们始终与底部和顶部对齐是理想的。

 .gallery { min-height: 980px; } .gallery .row{ display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; } 
 <div class="container-fluid gallery"> <div class="row"> <div class="col-sm-5"> <a href="#"><img src="http://lorempixel.com/528/980/technics" class="img-responsive"></a> </div> <div class="col-sm-4"> <a href="#"><img src="http://lorempixel.com/409/490/technics" class="img-responsive"></a> <a href="#"><img src="http://lorempixel.com/409/490/technics" class="img-responsive"></a> </div> <div class="col-sm-3"> <a href="#"><img src="http://lorempixel.com/324/327/technics" class="img-responsive"></a> <a href="#"><img src="http://lorempixel.com/324/327/technics" class="img-responsive"></a> <a href="#"><img src="http://lorempixel.com/324/327/technics" class="img-responsive"></a> </div> </div> </div> 

Here is the Bootply: http://www.bootply.com/mb2Ez6G7r8 这是Bootply: http//www.bootply.com/mb2Ez6G7r8

Hi Paul you can resolve in that way, i see that you use boostrap you dont need the property flex in your css. 嗨保罗你可以这样解决,我看到你使用boostrap你不需要你的CSS中的属性flex。

<div class="row">
<div class="col-sm-5">
   <a href="#"><img src="https://www.jssor.com/demos/img/paint/01.jpg"></a>
</div>

<div class="col-sm-4">
    <a href="#"><img src="https://www.jssor.com/demos/img/paint/02.jpg"></a>
    <a href="#"><img src="http://lorempixel.com/409/490/technics" class="img-responsive"></a>
</div>

<div class="col-sm-3">
    <a href="#"><img src="https://www.jssor.com/demos/img/paint/06.jpg" class="img-responsive"></a>

and your css 和你的CSS

.gallery {
min-height: 980px !important;}

dont forget add bootrap in your html 别忘了在你的HTML中添加bootrap

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

i explain why you dont need flex, Boostrap make your thml responsive with class .row and you can fill this with 12 columns that is why you have col-sm-(Number) in your case 5+4+3=12 if you want you can read more in this link grid systemn 我解释了为什么你不需要flex,Boostrap使你的thml响应类.row你可以用12列填充这就是为什么你有col-sm-(数字)在你的情况下5 + 4 + 3 = 12如果你想你可以在这个链接网格systemn中阅读更多内容

.column-sm-4{
   display: flex;
   flex-direction: row;
}

If height is an issue you should probably use background-image with css instead of <img> element. 如果高度是个问题,你应该使用带有css的background-image而不是<img>元素。 Hope this will solve the issue. 希望这能解决问题。

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

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