-1

I am using the bootstrap 4 and wanted to know how I leave all the columns of the same height ? If possible without using flexbox to be compatible with older browser ( bah !).

Thank you

Angelo Merlo
  • 427
  • 1
  • 5
  • 12

3 Answers3

1

Use the first two solutions of this answer. The third solution involves a flexbox, but as you mentioned, you don't want that.

In case link doesn't work, here is 1st solution: (Use with caution)

.row {
    overflow:hidden;
}
[class*="col-"]{
    margin-bottom:-99999px;
    padding-botton:99999px;
}

Solution 2: (Tables)

.row {
   display:table;
}
[class*="col-"] {
    float:none;
    display:table-cell;
    vertical-align:top;
}
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
  • 1
    As mentioned in the other answer, these solutions don't really work as they break column wrapping and responsiveness. http://codeply.com/go/tPLjH5r6dJ – Carol Skelly Jul 05 '16 at 18:34
  • You should know right off the bat that if a solution is proposing you add `-99999px` to your styles, then it's obviously a total hack solution and should be used with extreme caution. – ESR Sep 11 '17 at 03:46
  • @ArnavBorborah the comment is for future visitors of this page from Google, but you're welcome. – ESR Sep 15 '17 at 02:06
0

Do you want the content of the columns to be equal height? Bootstrap 4's equal height cards can be used for this. This uses display:table and display:table-cell when flexbox is not enabled.

UPDATE

Now that Bootstrap 4 (alpha 6) is flexbox by default, the columns are always equal height: http://www.codeply.com/go/m20UAOFw79

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
-2

Here is what you do if you want to use flexbox

The CSS

.row.is-flex {
    display: flex;
    flex-wrap: wrap;
}
.row.is-flex > [class*='col-'] {
    display: flex;
    flex-direction: column;
}

/*
* And with max cross-browser enabled.
* Nobody should ever write this by hand. 
* Use a preprocesser with autoprefixing.
*/
.row.is-flex {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

.row.is-flex > [class*='col-'] {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
}

The html

<div class="row is-flex">
    <div class="col-sm-4">...</div>
    <div class="col-sm-4">...</div>
    <div class="col-sm-4">...</div>
</div>

source (https://scotch.io/bar-talk/different-tricks-on-how-to-make-bootstrap-columns-all-the-same-height)

Ayrad
  • 3,996
  • 8
  • 45
  • 86