I have a indefinite amount of in-line elements being output. Now, depending on browser width, some elements will, of course, wrap to a new line. Is it possible to detect and single out these rows of elements or does the dom just see it as one large line?
Thanks for the help!!
EDIT: Trying to detect wrapped elements via offset height(Thanks Matchu). Wrapped elements output same values(total height of the element) as those found on the first row though. Any reason why?
$('#content').children().each(function() {
alert($(this)[0].offsetHeight);
});
You can check the offsetHeight
property of the elements and watch for it to jump. When an inline element has a greater offsetHeight
than the previous element, this element is on a new line.
element.getClientRects() when done on an inline element that is wrapped will return an array, with an rect object for each line. Bowser support is limited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With