Lets say I have a container div, inside of which are div containers of class ‘icon’
e.g.
<div class="icons clearfix">
<div class="icon">...</div>
<div class="icon">...</div>
<div class="icon">...</div>
<div class="icon">...</div>
<div class="icon">...</div>
etc...
</div>
The width of icons is 100% and sits in a fluid width container. ‘icon’ containers have a fixed with of 100px ( for purposes of example, though it could be something else).
Given an element representing a div.icon element, how do we determine what position in which row the element is currently in while accounting for browser or container resizing? The first item in the first row? The second item in the fifth row??
If you can assume that the height of
.iconclasses is fixed then you can determine it like that:.position().topposition value with the.icondiv height.position().leftis 0.Here’s a working fiddle: http://jsfiddle.net/vK3an/