jquery offset incorrect on floating elements

Go To StackoverFlow.com


I have a bunch of images each with the float: left property applied to them. They are constrained withing a 400px width area, forcing them into a grid of 4 X 4. If i try to get the position of them, they are always incorrect. What is causing this? You can see what I'm trying to do here: http://dev.redemptionconnect.com/cards/browse. Click one of the images to see what I mean. the dialog that pops up should be over the image you clicked.

2012-04-03 23:25
by LordZardeck
The code in your site is horrendous when I view-source. Try posting the related code directly into the question - Jasper 2012-04-03 23:30
wow. that is so weird. it's nice and formatted in my source file. one se - LordZardeck 2012-04-03 23:31
http://pastebin.com/raw.php?i=1zd1h4TV that's the source fil - LordZardeck 2012-04-03 23:32


The way I see it, you should be checking the offset of the actual floated elements: the underlying <img>. They are in fact detached from the inline layout nature of the links when floated, leaving the links at top:0;left:0.

You could as well, get rid of the <a> and apply that click event to the images. Or float:left the <a>, whatever your prefer.

2012-04-04 00:01
by keystorm
applying the click to the img just allowed for the left position to be correct. the top is still wron - LordZardeck 2012-04-04 00:21
ok, it had to do with the line height. thanks - LordZardeck 2012-04-04 00:36
A display:block to the <img> would fix that too. Great it helped - keystorm 2012-04-04 11:13