I want to make all the columns to same height in a row. So, all columns in a row should have the same height as any column with max height.
Fiddler: https://jsfiddle.net/ebwwvy6m/11/
<div class="container-fluid">
<div class="row">
<div class="col-sm-2 bg-warning">
This is a col-sm-2
Some test content
Some test content
Some test content
Some test content
</div>
<div class="col-sm-6 bg-success">
.col-sm-6
</div>
<div class="col-sm-4 bg-info">
.col-sm-4
Some test content
Some test content
</div>
</div>
</div>
Issue:
Both column 2 and column 3 should expand to have the same height as column 1.
Any help / suggestion will be greatly appreciated.
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.
As of 2017, the best (and easiest) way to make equal height columns in a responsive design is using CSS3 flexbox. Now we have columns that are equal in height, and their content fills the full height ot the entire column.
3 Answers. Show activity on this post. You just have to use class="row-eq-height" with your class="row" to get equal height columns for previous bootstrap versions.
This is done by adding the class “col-SIZE-SIZE_TO_OCCUPPY”. For example, . col-md-4 which means take 4 columns on the medium-sized screens. If we stack multiple column classes on a single element we can define how we want the layout to look like on other screens and change the columns to rows as we want.
.row-eq-height{
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
Add this class with your row class.
<div class="container-fluid">
<div class="row-eq-height row">
<div class="col-sm-2 bg-warning">
This is a col-sm-2
Some test content
Some test content
Some test content
Some test content
</div>
<div class="col-sm-6 bg-success">
.col-sm-6
</div>
<div class="col-sm-4 bg-info">
.col-sm-4
Some test content
Some test content
</div>
</div>
</div>
https://jsfiddle.net/ebwwvy6m/16/
The best way to do this is using display:flex;
on the parent row
and on the col
.
Working Demo.
.example {
display: flex;
}
.example .exaple-items {
display: flex;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row example">
<div class="col-sm-2 bg-warning exaple-items">
This is a col-sm-2
Some test content
Some test content
Some test content
Some test content
</div>
<div class="col-sm-6 bg-success exaple-items">
.col-sm-6
</div>
<div class="col-sm-4 bg-info exaple-items">
.col-sm-4
Some test content
Some test content
</div>
</div>
</div>
Since flextbox
is a new CSS feature check the browser compatibility: caniuse.com
And use the vendor prefix
:
.example {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
If you want to know more about display:flex;
read this: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
P.S. The new bootstrap v4 will have this feature integrated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With