jquery gets the absolute position and relative position of the HTML element

Source: Internet
Author: User

jquery gets the absolute position coordinates of the HTML element and the position coordinate method of the relative parent element:


Absolute position Coordinates:
$ ("#elem"). Offset (). Top
$ ("#elem"). Offset (). Left


Position coordinates relative to parent element:
$ ("#elem"). Position (). Top
$ ("#elem"). Position (). Left

Other:
Static (default): The default positioning method.
Relative (relative positioning): On the basis of static, relative elements of the original position change, by setting the Top,bottom,left,right implementation.
Absolute (absolute positioning): is relative to the parent element, if there is relative in the parent element, then the position of the element is the computed result. That is, the reference to absolute positioning is "the last positioned parent element (static not counted)". Absolute positioning causes the element to be deleted from the document stream.
Fixed position: the reference to the fixed position is always the current document. With fixed positioning, it's easy to have a div positioned on top left and right in the browser document.

jquery gets the absolute position and relative position of the HTML element

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.