I found a solution in this article (in English): "Bootstrap 3 Responsive Columns of same height". It creates a set of classes to ensure that all columns in a row are the same height. Those that interest you in this case are:
.row-same-height {
display: table;
width: 100%;
/* fix overflow */
table-layout: fixed;
}
@media (min-width: 768px) {
.col-sm-height {
display: table-cell;
float: none !important;
}
}
(there are others for the other resolutions - xs
, md
and lg
- as well as others that give you different types of control)
Example:
.row div {
border: 1px solid black; // Para visualização; não usar na prática
}
.row-same-height {
display: table;
width: 100%;
/* fix overflow */
table-layout: fixed;
}
@media (min-width: 768px) {
.col-sm-height {
display: table-cell;
float: none !important;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class='container'>
<div class='row row-same-height'>
<div class='col-xs-12 col-sm-5 col-sm-height' contentEditable="true">
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
<p>CONTEUDO 1</p>
</div>
<div class='col-xs-12 col-sm-7 col-sm-height' contentEditable="true">
CONTEUDO 2
</div>
</div>
</div>
See the example in "Whole page" to see the effect. I put the div
s with contentEditable
so you can edit them and see how the content adapts to the height of the largest column, plus an edge to assist in visualization, these tricks should not be present in the actual code.
I know how to do it using Flexbox, but I’m pretty sure that would make it impossible to use with the custom Bootstrap classes... Your Ivs have predictable height, or it’s variable?
– mgibsonbr
completely variable.
– Murilo Man
I don’t think it’s duplicate because in this case it’s with Bootstrap.
– Jorge B.