JQ size and Position summary (width scrolltop position offset)

Source: Internet
Author: User

First, talk about the size of the elements, this use a lot.

1. Width (). Height () Gets the width of the element, and does not contain units, equivalent to the native offsetwidth, but note 2 points

  The native result contains the unit, and is not able to get to the wide height of the hidden element.

2. Innerwidth (). Innerheight ()//equivalent to Width+padding

3. Outerwidth (). Outerheight ()//equivalent to width + padding + border

4. Outerwidth (True). Outerheight (TRUE)//equivalent to width + padding + border + margin

The above several usages use quite a lot of, also used before, but note that these methods can not only be used to obtain, but also can be used to set up, for example,. Outerwidth (200,true);

The width of the viewable area, $ (window). Height ();

The height of the page, $ (document). Height ();

Page scrolling distance, $ (document). ScrollTop (); available here or set.

Second, distance location

$ (). Offset (). Left//element to the entire page distance, notice here left and top without parentheses (often make mistakes!) )

$ (). Position (). Left//element to the location of the ancestor node distance, if not found, it is the distance to the page (note this is the margin value)

JQ size and Position summary (width scrolltop position offset)

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.