api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

Offset does not support "accounting for body margins/borders/padding": unclear what "accounting for" means

Open teo1978 opened this issue 11 years ago • 4 comments

Regarding .offset()

http://api.jquery.com/offset/

"Note: jQuery does not support [...] accounting for borders, margins, or padding set on the body element."

It's not clear what "accounting for" means. Does it mean that the offset is computed relative to the whole body including the body's margins? Or does it mean the opposite, that it is relative to the inner box of the body?

teo1978 avatar Jul 13 '13 20:07 teo1978

I believe it means that if you do any of that, the results may be wrong and inconsistent across browsers. @dmethvin Can you verify?

scottgonzalez avatar Jul 13 '13 21:07 scottgonzalez

Oh, that would be awful. Not being able to compute offsets of anything if the body has padding would be an unacceptable limitation

teo1978 avatar Jul 13 '13 21:07 teo1978

I believe we removed these limitations in 1.9, so the docs need to be changed (after re-verifying we got it right).

http://bugs.jquery.com/ticket/11542

https://github.com/jquery/jquery/pull/899

@matteosistisette can you check that the body is being handled the way you expect?

dmethvin avatar Jul 14 '13 03:07 dmethvin

Body margins seems to be accounting by offset: http://jsfiddle.net/xrdfo0h8/

Is there some edge cases or can this note be removed from the api?

bcaudan avatar Feb 09 '15 14:02 bcaudan