I'm using Bootstrap. How can I make three columns all the same height?
Here is a screenshot of the problem. I would like the blue and red columns to be the same height as the yellow column.
Here is the code:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-xs-4 panel" style="background-color: red">
some content
</div>
<div class="col-xs-4 panel" style="background-color: yellow">
catz
<img width="100" height="100" src="https://lorempixel.com/100/100/cats/">
</div>
<div class="col-xs-4 panel" style="background-color: blue">
some more content
</div>
</div>
</div>
From:
http://getbootstrap.com.vn/examples/equal-height-columns/equal-height-columns.css
cheeky jquery solution if anyone's interested. Just make sure all your cols (el) have a common classname...works responsively too if you bind it to $(window).resize
Usage
Note: This post has been edited as per @Chris' comment out that the code was only set the last highest height in the
$.each()
functionhere is my solution (compiled CSS):
So your code would look like:
Basically this is the same system you use with
.col-*
classes with that difference you need to apply.row-*
classes to the row itself.With
.row-sm-eq
columns will be stacked on XS screens. If you don't need them to be stacked on any screens you can use.row-xs-eq
.The SASS version that we do actually use:
Live demo
Note: mixing
.col-xs-12
and.col-xs-6
inside a single row would not work properly.You can use below code
You can use inline-flex as well which works pretty good and may be a little cleaner than modifying every row element with CSS.
For my project I wanted every row who's child elements had borders to be the same height so the borders would look jagged. For this I created a simple css class.
I'm surprised I couldn't find a worthwhile solution here late 2018. I went ahead and figured it out a Bootstrap 3 solution myself using flexbox.
Clean and simple example:
HTML
CSS
View working demo: http://jsfiddle.net/5kmtfrny/