Last active
February 3, 2017 11:39
-
-
Save arturmamedov/54c38b4c29eeae5325ad909d4acbf3d8 to your computer and use it in GitHub Desktop.
Equl Height for elements
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
<script> | |
/** | |
* Boxes AutoHeight | |
* | |
* @param columns | |
* | |
* data-weh-add="50" add 50px to all | |
*/ | |
function withEqualHeight(columns) { | |
var tallestcolumn = 0, add = parseInt(columns.first().attr('data-weh-add')); | |
if (isNaN(add)) { | |
add = 0; | |
} | |
columns.each( | |
function () { | |
$(this).css('height', 'auto'); | |
var currentHeight = $(this).height(); | |
if (currentHeight > tallestcolumn) { | |
tallestcolumn = currentHeight; | |
} | |
} | |
); | |
columns.height(tallestcolumn + add); | |
} | |
// .withAutoHeight > .weh for all elements | |
$('.withEqualHeight').each(function () { | |
withEqualHeight($(this).find('.weh')); | |
}); | |
</script> | |
<div class="withEqualHeight"> | |
<h2 class="text-center">News</h2> | |
<div class="col-sm-6 col-lg-4 weh" data-weh-add="50"> ... content inside with + 50px ... </div> | |
<div class="col-sm-6 col-lg-4 weh"> ... content inside ... </div> | |
<div class="col-sm-6 col-lg-4 weh"> ... content inside ... </div> | |
<div class="col-sm-6 col-lg-4 weh"> ... content inside ... </div> | |
<div class="col-sm-6 col-lg-4 weh"> ... content inside ... </div> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See withplugins.js for more https://github.com/arturmamedov/withFront