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>
No JavaScript needed. Just add the class
.row-eq-height
to your existing.row
just like this:Tip: if you have more than 12 columns in your row, the bootstrap grid will fail to wrap it. So add a new
div.row.row-eq-height
each 12 columns.Tip: you may need to add
to your html
You can wrap the columns inside a div
Here is my method, i have used flex with some changes in media query.
then added the classes to the parent which were required.
I am using responsive breakpoints because flux usually hampers the bootstrap standard responsive nature.
Thought I'd just add that the answer given by Dr.Flink can also be applied to a Bootstrap 3
form-horizontal
block - which can be very handy if you want to use background colours for each cell. In order for this to work for bootstrap forms, you would need to wrap the form contents which just serves to replicate a table-like structure.The example below also provides the CSS which demonstrates an additional media query allows Bootstrap 3 to simply takeover and do it's normal thing on the smaller screen(s). This also works in IE8+ .
Example:
You only show one row so your use case may be limited to just that. Just in case you have multiple rows, this plugin - github Javascript-grids - works perfectly! It makes each panel expand to the tallest panel, giving each row potentially a different height based on the tallest panel in that row. It's a jquery solution vs. css, but wanted to recommend it as an alternative approach.
Try this do through flex-box
Live JSFiddle - https://jsfiddle.net/grinmax_/spsn4fnq/