By simply declaring display: flex
on a wrapping parent will work. That means that you will have to wrap your columns in a new <div>
, e.g.:
<div class="row row-equal-height">
<div class="col-xs-3" id="left">
<p>short</p>
</div>
<div class="col-xs-3" id="right">
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
</div>
</div>
For your CSS, you can do this:
.row-equal-height {
display: flex;
}
However, this means that you will have to rely on browser support for CSS3 flexbox specification. The good news that, with vendor prefixes, it is surprisingly very widely supported today (>97%).
See proof-of-concept below:
#left {
background-color: red;
}
#right {
background-color: green;
}
.row-equal-height {
display: flex;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="row row-equal-height">
<div class="col-xs-3" id="left">
<p>short</p>
</div>
<div class="col-xs-3" id="right">
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
</div>
</div>
</body>
Last-ditch solution: display: table
You should consider this as a last-ditch solution, because as we all know, you should not be using tables for layout purposes. However, if you want to support browsers that do not support flexbox at all (cue IE9 and below), this might be your only way out:
#left {
background-color: red;
}
#right {
background-color: green;
}
.wrapper {
display: table;
border-collapse: collapse;
width: 50%;
}
.row {
display: table-row;
}
.row > div {
display: table-cell;
float: none;
width: 50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="wrapper">
<div class="row">
<div class="col-xs-3" id="left">
<p>short</p>
</div>
<div class="col-xs-3" id="right">
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
<p>long</p>
</div>
</div>
</div>
</body>