Created
February 15, 2017 19:44
-
-
Save chancesmith/428834ffc1d7a772cad025b1d9aabc1f to your computer and use it in GitHub Desktop.
Bootstrap Equal Height columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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