Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13696 closed bug (notabug)

jquery.offset().top returns a different position in Firefox and Chrome

Reported by: j.vanhees@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

When calling jQuery.offset().top in Chrome and Firefox, the number is much higher in Firefox than Chrome. I've tried removing all margin / padding (* { margin: 0; padding: 0; }), line-heights, but that shouldn't make a difference.

Testcase: http://www.bluebillywig.tv/jorick/inview/

Offset().top get's logged in the console on scroll.

Change History (8)

comment:1 Changed 6 years ago by j.vanhees@…

comment:2 Changed 6 years ago by tylercrompton

Does this cause any unexpected behavior (other than the obvious difference in values)?

comment:3 in reply to:  2 Changed 6 years ago by j,vanhees@…

Replying to tylercrompton:

Does this cause any unexpected behavior (other than the obvious difference in values)?

No, but the answer the function gives back isn't correct (as far as I can measure).

comment:4 Changed 6 years ago by m_gol

You have incorrect markup - span cannot contain div and the element you measure has div children which causes different behavior in Firefox (which doesn't extend span to contain div children) and Chrome (which does extend it). This causes different values to be returned from element.getBoundingClientRect() and - in consequence - different offset() values.

I'll leave it to others but for me it's notabug, you just should correct your markup.

comment:5 Changed 6 years ago by m_gol

Resolution: notabug
Status: newclosed

I'm closing it since it's caused by real difference in element sizes and positions in these browsers so jQuery correctly shows the difference.

comment:6 Changed 6 years ago by j.vanhees@…

I understand, but the top of the element is at the same position in different browsers. That the height of the element has a different value, shouldn't make a difference, right?

comment:7 Changed 6 years ago by m_gol

No, the bottom is in the same position, top differs. Open Firebug & Chrome Web Inspector and you'll see.

comment:8 Changed 6 years ago by j.vanhees@…

You are correct indeed, the span is only around 20 pixels in height. I can fix this myself with a wrapper div, thanks for your time!

Note: See TracTickets for help on using tickets.