html - Jquery - Get the highest height out of three different divs -
i'm working on pinterest based grid system, everything's fine , dandy , working except 1 thing. problem being because i'm using absolute positioning container wraps them has set actual pixels, came code:-
$(document).ready(function(){ $('.newspagemain').css({height:(($('#newsentry:nth-child(1)').height()) + ($('#newsentry:nth-child(4)').height()) + ($('#newsentry:nth-child(7)').height()) + 141)}); // id 9 });
it works degree problem is, if row longer, longest 1 cropped off, want able work out highest of nth-chlds 1,2,3 4,5,6 7,8,9 can add highest container wrap correctly
i hope makes sense, appreciated
thank you
~matt
if understand correctly want tallest element every group of 3 elements in collection:
var $els = $('#newsentry div'), height = 0; (var = 0; < $els.length; += 3) { height += math.max.apply(null, $divs.slice(i, i+3).map(function() { return $(this).height(); }).get()); }
if want height including padding , margin, you'd use outerheight()
.
Comments
Post a Comment