The coordinate system in HTML and its application in mouseevent and element box

Source: Internet
Author: User

The coordinate system in HTML and its application in mouseevent and element box

HTML has four coordinate systems: screen, page,client, and offset, which describe the box dimensions of DOM elements and

The position in the MouseEvent,

Screens: Screen coordinate system, (SCREENX,SCREENX), the upper-left corner of the screen is (0,0), which is independent of the window, regardless of how the browser's window is moved and scaled, the origin of the screens coordinate system is always in the upper left corner of the display, and W and H are unchanged.

Page: Coordinate system, (PageX, Pagey), the upper-left corner of the page is (0,0)

Client: Customer area coordinate system, (ClientX, ClientY), local (DOM conten0074) coordinate system,

Offset: Shift coordinate system (OffsetX, OffsetY), relative to target node's padding Edge, he is the most varied because his benchmark, target node, is constantly changing as the mouse moves.

Note: x, y: Aliases for Clientx and clienty coordinates, respectively, belong to the client coordinate system

Note: The coordinate units in this are browser coordinate units, not the physical resolution of the display,

For example: the resolution of the display is, 1920 * 1200, but the browser coordinates are only 1280*800

Window object is Document.defaultview

Where Window.outerheight is the height of the entire window, and window.innerheight. Just browser's client area.

(viewport), the difference between the two is browser own occupied title area and address bar area

In full screen mode (completely hide browser title and Address bar), window.outerheight = = = Window.innerheight = = = Screen.height

Offsetheight, ClientHeight, scrollheight?

The height of the div element

Elmnt.clientheight: "Viewable" height, including padding, not including border, scrollbar or margin.

Elmnt.offsetheight:

If the content length of an element is higher than the actual height of the element, this viewable height returns only the height of the visible part

offsetheight:viewable height, including padding, border and ScrollBar.

The coordinate system in HTML and its application in mouseevent and element box

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.