The difference between offsetwidth/clientwidth

Source: Internet
Author: User

ClientWidth is the width that the object sees (without edges, that is, border)

ScrollWidth is the width of the actual content of the object (if there is no padding, that is the distance between the borders, if there is padding, the distance between the left padding and the right padding).

Offsetwidth refers to the width of the object itself, the integer type, in pixels (with edges, such as the width of the scroll bar, and the value changes as the content is entered).

ScrollWidth: The width of the actual content of the object, without the edge width, becomes larger when the content in the object exceeds the visible area.
ClientWidth: The width of the visible area of the object content, the edges such as the scroll bar, and so on, will change with the size of the object display.
Offsetwidth: The actual width of the object as a whole, and the edges of the package scroll bar, will change as the object's display size changes.

ScrollHeight: Gets the scroll height of the object.
ScrollLeft: Sets or gets the distance between the left edge of the object and the leftmost of the currently visible content in the window
ScrollTop: Sets or gets the distance between the top of the object and the top of the visible content in the window
ScrollWidth: Gets the scrolling width of the object
Offsetheight: Gets the height of the object relative to the layout or parent coordinates specified by the parent coordinate OffsetParent property
Offsetleft: Gets the calculated left position of the object relative to the layout or the parent coordinate specified by the OffsetParent property
OffsetTop: Gets the computed top position of the object relative to the layout or the parent coordinate specified by the OffsetTop property

Easy to confuse points:

ClientX Sets or gets the position of the mouse pointer relative to theCurrent WindowThe x-coordinate where the customer area does not include controls and scrollbars for the window itself.
ClientY Sets or gets the position of the mouse pointer relative to theCurrent WindowThe y-coordinate where the customer area does not include the control and scroll bars of the window itself.
OffsetX Sets or gets the position of the mouse pointer relative to theThe object that triggered the eventX-coordinate.
OffsetY Sets or gets the position of the mouse pointer relative to theThe object that triggered the event's y-coordinate.
ScreenX Sets or gets the position of the mouse pointer relative to the userScreenX-coordinate.
ScreenY Sets or gets the position of the mouse pointer relative to the userScreen's y-coordinate.
x Sets or gets the X-pixel coordinates (that is, relative to the current window) of the position of the mouse pointer in relation to the parent document .
y Sets or gets the Y-pixel coordinates (that is, relative to the current window) of the position of the mouse pointer in relation to the parent document .

Document.documentElement.scrollTop The vertical scrolling value
Event.clientx+document.documentelement.scrolltop horizontal coordinates of relative documents + amount of vertical scrolling
The above mainly refers to IE, Firefox differences are as follows:
IE6.0, ff1.06+:
clientwidth = width + padding
clientheight = height + padding
offsetwidth = width + padding + border
offsetheight = height + padding + border
ie5.0/5.5:
ClientWidth = Width-border
ClientHeight = Height-border
offsetwidth = width
offsetheight = height (need to mention: the Margin property in CSS, and clientwidth, Offsetwidth, ClientHeight, offsetheight)


page visible area width: DOCUMENT.BODY.CLIENTWIDTH;
page visible Area High: document.body.clientHeight;

Web page Visible Area width: document.body.offsetWidth (including the width of the edge); Web page Visible Area High: document.body.offsetHeight (including the width of the edge);

Page body Full text width: document.body.scrollWidth; Page body Full text High: document.body.scrollHeight;

The page was rolled High: document.body.scrollTop; The webpage is rolled away left: document.body.scrollLeft;

Page body part: window.screentop; Page body part left: window.screenleft;

High screen resolution: window.screen.height; Width of screen resolution: Window.screen.width;

Screen available working area height: window.screen.availHeight; Screen available working area width: window.screen.availWidth;

The difference between offsetwidth/clientwidth

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.