javascript - Columns child equal per row -
i have product gallery needs equal in height parent , child div.
i need calculate per row. i'm getting tallest child , applying on div. want highest div , apply row.
$(document).ready(function() { var item_title_height = 0; var item_details_height = 0; $('.item-title').each(function(i, obj) { if($(this).height() > item_title_height) { item_title_height = $(this).height(); } }); $('.item-details').each(function(i, obj) { if($(this).height() > item_details_height) { item_details_height = $(this).height(); } }); $(".item-title").height(item_title_height); $(".item-details").height(item_details_height); });
this fiddle
hope can me
not sure how in jquery. find largest div vanilla. use window.getcomputedstyle styling info elements may not have explicit css or html style declarations.
var heights = array.prototype.slice.call(document.getelementsbyclassname('item-title')).map(function(i){ var cs = window.getcomputedstyle(i,null) return parsefloat(cs.getpropertyvalue("height")) }); alert(math.max.apply(null,heights))
Comments
Post a Comment