Opened 10 years ago
Closed 10 years ago
#12592 closed bug (invalid)
something wrong with $.fn.offset
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
write a test page:
<!DOCTYPE html> <html style="border:solid black 2px;margin:1px;padding:4px"> <head> <meta charset="utf-8"> <script src="jquery-1.8.0.js"></script> <script> $(function() { var a=""; for(var i=0;i<100;i+=1) a+="aa<br>"; $("div").html(a); var div = $("div")[0], doc = div.ownerDocument.documentElement, body = div.ownerDocument.body; window.div = div; window.doc = doc; window.body = body; }) </script> </head> <body style="border:solid red 16px;margin:8px;padding:32px"> <div id="only" style = "border:solid blue 128px;margin:64px;padding:256px"> </div> </body> </html>
$(div).offset().top == 125, the distance from the outerline of the margin of <html> element to the outline of the border of the <div> element, minus the height of the border of <html> element.
set $(doc).css("border","");
$(div).offset().top == 109, the distance from the outline of the margin of <html> element to the outline of the border of the <div> element, minus the height of the border of "<body>" element.
set back $(doc).css("border","solid black 2px")
$(body).offset().top == 8, the distance from "the innerline of the padding of <html> element" to the outline of the border of the <div> element, minus "nothing".
What is the meaning of "relative to the document"?
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.
comment:3 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
The above is tested in Chrome.
In firefox,
$(div).offset().top == 111, the distance from the outerline of the margin of <html> element to the outerline of the "margin" of the <div> element, minus the height of the border of "<body>" element.
$(body).offset().top === -8, the distance from the innerline of the padding of the <html> element to the outline of the border of the <body> element, minus "the height of the border of <body> element".