Skip to content

position() function reports incorrect left offset under Chrome #2237

@ghost

Description

Test this
https://jsfiddle.net/Reimu/yu3c361g/2/
under Chrome and other browsers, you will see the left offset reported by position() method is incorrect under Chrome.

The value of left offset under Chrome is the gap between <html> and <body>, not the real left offset of the horizontally centered <div>.

This problem relates only with horizontally centered <div>s, and can be fixed by calculating manually with the marginLeft value of the element's computed style and the gap between <html> and <body>.

Maybe this is due to a possible bug / design choice of Chrome, as there are also some discussion about it on StackOverflow. But I think jQuery is supposed to deal with such difference between browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions