Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object offset() does not take margin into consideration. #120

Open
magebarf opened this issue May 1, 2013 · 3 comments
Open

Object offset() does not take margin into consideration. #120

magebarf opened this issue May 1, 2013 · 3 comments

Comments

@magebarf
Copy link

magebarf commented May 1, 2013

The offset function does not include explicitly set margins in its calculations if parents are relatively positioned. This makes the values returned not quite match the expected values for elements using it.

The odd part seems to be that auto margins seems to be calculated correctly (when running through chrome at least).

I've made a clear and stripped down example of this available at:
http://sargy.net/testcase/bonzo/offset.html

(jsFiddle tucks the html inside their layout, so the offset values there is not as easy to know if they are wrong)

@magebarf
Copy link
Author

magebarf commented May 2, 2013

Same behavior verified with latest stable versions on Windows 8 (above mentioned chrome being run on OS X):

  • Opera 12.15
  • FireFox 20.0.1
  • Chrome 26.0.1410.64
  • Maxthon 4.0.5.4000
  • Internet Explorer 10.0.9200.16540

@ryanve
Copy link
Contributor

ryanve commented May 2, 2013

The issue seems isolated to when the body is position:relative. If the body is in its natural position:static then descendent offsets seem correct even when relative. Do your findings agree?

@magebarf
Copy link
Author

magebarf commented May 2, 2013

Yes, indeed you are right.

The drawbacks of being in a too simple sandbox for testing to start off with. :)

If body has relative position then elements place as direct child will not include the margin.
If a element has no parent nodes other than the body element which has a position attribute (and the body has relative position set), the same case applies it seems, I whipped together a small example similar to my first one:

http://sargy.net/testcase/bonzo/offset2.html
(and sorry for hurting your eyes with my attempts to make things as clear as possible) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants