Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same height column bootstrap 3 row responsive

Hi I have four divs in a bootstrap row. I want all divs in this row to have the same height and not break responsibility. I don't know how to do this without breaking responsibility.

I have tried solving this with fixed heights but in terms of responsiveness this is a bad solution.

Thanks :-)

<div class="row">     <div class="col-md-3 index_div_item">         <a href="#">         <div class="well" id="item1">                 <h1 class="h1_item"><span class="titre_item">Title</span></h1>                 <h2 class="h2_item_glyphicon"><span class="glyphicon glyphicon-ok-circle"></span></h2>                 <p>sidiis amicorum mariti inops cum liberis uxor alitur Reguli et dotatur ex aerario filia Scipionis, cum nobilitas florem adultae virginis diuturnum absentia pauperis erubesceret patr</p>                         </div>         </a>     </div>         <div class="col-md-3 index_div_item">         <a href="#">             <div class="well" id="item2">                 <h1 class="h1_item"><span class="titre_item">Title</span></h1>                 <h2  class="h2_item_glyphicon"><span class="glyphicon glyphicon-stats"></span></h2>                 <p>sidiis amicorum mariti inops cum liberis uxor alitur Reguli et dotatur ex aerario filia Scipionis, cum nobilitas florem adultae virginis diuturnum absentia pauperis erubesceret patr</p>             </div>           </a>     </div>         <div class="col-md-3 index_div_item">         <a href="#">             <div class="well" id="item3">                 <h1 class="h1_item"><span class="titre_item">Title</span></h1>                 <h2  class="h2_item_glyphicon"><span class="glyphicon glyphicon-send"></span></h2>                 <p>sidiis amicorum mariti inops cum liberis uxor alitur Reguli et dotatur ex aerario filia Scipionis, cum nobilitas florem adultae virginis diuturnum absentia pauperis erubesceret patr</p>             </div>         </a>      </div>       <div class="col-md-3 index_div_item">         <a href="#">             <div class="well" id="item4">                 <h1 class="h1_item"><span class="titre_item">Title</span></h1>                 <h2  class="h2_item_glyphicon"><span class="glyphicon glyphicon-cog"></span></h2>                 <p>sidiis amicorum mariti inops cum liberis uxor alitur Reguli et dotatur ex aerario filia Scipionis, cum nobilitas florem adultae virginis diuturnum absentia pauperis erubesceret patr</p>                             </div>           </a>       </div>               </div> 
like image 837
user3279494 Avatar asked Apr 25 '14 07:04

user3279494


People also ask

How do I make Bootstrap 3 columns equal height?

You should be using a custom selector for one and two the tables styles should not be applied to [class*='col-'] that have defined widths. This method should ONLY be used if you want equal height AND equal width columns. It is not meant for any other layouts and is NOT responsive.

How do I make Bootstrap 4 columns equal height?

You just have to use class="row-eq-height" with your class="row" to get equal height columns for previous bootstrap versions.

How do I keep two side by side DIV elements the same height?

Basically what you do is make both divs/columns very tall by adding a padding-bottom: 100% and then "trick the browser" into thinking they aren't that tall using margin-bottom: -100% .


2 Answers

You can achieve this by using javascript. Find out the biggest height of the 4 divs and make all of them at the same height like the biggest one.

Here is the code:

$( document ).ready(function() {     var heights = $(".well").map(function() {         return $(this).height();     }).get();      maxHeight = Math.max.apply(null, heights);      $(".well").height(maxHeight); }); 

edit history: changed the ',' sign into ';' sign

like image 180
paulalexandru Avatar answered Sep 18 '22 15:09

paulalexandru


There was at one point an official experimental example of same-height columns using CSS flexbox with Bootstrap. Here's the gist of it:

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

And then use <div class="row row-eq-height"> instead of <div class="row">.

Note that flexbox isn't supported in IE<10.

like image 44
cvrebert Avatar answered Sep 18 '22 15:09

cvrebert