Skip to content

Instantly share code, notes, and snippets.

@chancesmith
Created February 15, 2017 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chancesmith/428834ffc1d7a772cad025b1d9aabc1f to your computer and use it in GitHub Desktop.
Save chancesmith/428834ffc1d7a772cad025b1d9aabc1f to your computer and use it in GitHub Desktop.
Bootstrap Equal Height columns
function eqHeight(className) {
var elements = $(className);
// loop through each element with said className
elements.each(function(i){
var targetHeight = 0;
$el = $(this);
// loop through immediate children
$el.children().each(function(i){
$child = $(this);
console.log($child);
if ($child.outerHeight() > targetHeight) {
targetHeight = $child.outerHeight();
console.log("here is the winner " + targetHeight);
}
});
// set equal height to largest height
$el.children().css({'min-height': targetHeight});
});
}
$(window).load(function() {
eqHeight('.eql');
});
$(window).resize(function(){
eqHeight('.eql');
});
<div class="container">
<div class="row eql">
<div class="col-md-3">
<h3>Individuals</h3>
<p>Lorem ipsum...</p>
</div>
<div class="col-md-3">
<h3>Lawmakers</h3>
<p>Lorem ipsum...</p>
</div>
<div class="col-md-3">
<h3>Stakeholders</h3>
<p>Lorem ipsum...</p>
</div>
<div class="col-md-3">
<h3>Media</h3>
<p>Lorem ipsum...</p>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment