Twitter Bootstrap 3 - Panels of Equal Height in a Fluid Row

Solution 1:

This can be done with CSS flexbox. Only minimal CSS is needed..

.equal {  
    display: -webkit-flex;
    display: flex;
}

Just add .equal to your .row and flexbox does the rest.

http://www.codeply.com/go/BZA25rTY45

UPDATE: Bootstrap 4 uses flexbox so there is no need for the additional CSS. http://www.codeply.com/go/0Aq0p6IcHs

Solution 2:

Bootstrap's solution - add this css and add the class to your row:

.row-eq-height {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display:         flex;
}

It has a couple caveats, as posted at http://getbootstrap.com.vn/examples/equal-height-columns/, but it sounds like it'll be good enough for your case.

I also saw this answer here.

Update for dynamic number of columns

Bootstrap automatically wraps columns into new rows when you add more than can fit in one row, but this flexbox approach breaks this. To get flexbox to wrap, I've found you can do something like this:

-webkit-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-align-content: flex-end;
align-content: flex-end;

This is awesome when you have a dynamic number of columns, or columns that change width according to the screen size. So you can have something like this:

<div class="row row-eq-height">
    <div class="col-sm-6 col-md-4">Content...</div>
    <div class="col-sm-6 col-md-4">Content...</div>
    <div class="col-sm-6 col-md-4">Content...</div>
    <div class="col-sm-6 col-md-4">Content...</div>
    <div class="col-sm-6 col-md-4">Content...</div>
</div>

And it all lines up the way it's expected. Just watch out - it only works in newer browsers. More info here

Solution 3:

If you're going to use the bootstrap grid, I don't think you're going to find an easy way to accomplish this without hacks like the following css.

This basically says. When the screen width is greater than the md breakpoint in bootstrap, give all the elements with panel-body class which are direct descendants of the column elements a minimum height of 420px which happens to be a "magic number" that works with your existing content.

Again, I think this is a really gross solution, but it "works" in a pinch.

@media (min-width: 992px) {
  .col-md-4 > .panel > .panel-body {
    min-height: 420px;
  }
}

Here's a CSS-Tricks article Fluid Width Equal Height Columns which covers various ways (display: table & flexbox) to accomplish this. However, you might need to step away from the responsive bootstrap grid for this particular task.

Also, here's the Complete Guide to Flexbox

Solution 4:

Haven't found any of these CSS methods to work in my case I am using images in my panels too instead I used a simple JQuery function to get the job done

        window.onload = function resizePanel(){
            var h = $("#panel-2").height();
            $("#panel-1").height(h); // add a line like this for each panel you want to resize
        }

Where the ids "panel-1" and and "panel-2" are in the panel tag choose the largest panel as the one you use to set h and call the function at the end of you html.

<body onresize = "resizePanel()">

I also make it so the function is called when if the window is resized by adding the onresize attribute to the body