I have several .col-md-2
elements on my Bootstrap website, each containing an image of varying height.
I am looking to ensure that all the columns have the same height so that I can align the images horizontally.
Below is the HTML code:
<div class="row">
<div class="col-md-2">
<img src="http://lorempixel.com/400/300/" alt="" />
</div>
<div class="col-md-2">
<img src="http://lorempixel.com/400/200/" alt="" />
</div>
<div class="col-md-2">
<img src="http://lorempixel.com/300/200/" alt="" />
</div>
<div class="col-md-2">
<img src="http://lorempixel.com/200/200/" alt="" />
</div>
<div class="col-md-2">
<img src="http://lorempixel.com/400/400/" alt="" />
</div>
</div>
Here is the CSS code:
.col-md-2 {
background-color: red;
}
.col-md-2:nth-child(odd) {
background-color: green;
}
.col-md-2 img {
max-width: 100%;
}
You can view a live example on JSFiddle
Is there a way I can achieve this layout?