Skip to content

Instantly share code, notes, and snippets.

@arturmamedov
Last active February 3, 2017 11:39
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 arturmamedov/54c38b4c29eeae5325ad909d4acbf3d8 to your computer and use it in GitHub Desktop.
Save arturmamedov/54c38b4c29eeae5325ad909d4acbf3d8 to your computer and use it in GitHub Desktop.
Equl Height for elements
<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>
@arturmamedov
Copy link
Author

arturmamedov commented Jan 14, 2017

See withplugins.js for more https://github.com/arturmamedov/withFront

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment