JavaScript DOM element width high

Source: Internet
Author: User

Get element position

    • The left distance of the offsetleft element relative to the parent element
    • The distance of the offsetheight element relative to the upper part of the parent element

The difference between offsetleft and Style.left

    • Offsetleft is read-only, Style.left is readable and writable, to change the position of the element, only using Style.left
    • Offset returns a string that is returned by a number;style.left, such as "30px"
    • Style.left need to be defined directly in HTML. Defined in a CSS style sheet, it is not possible to get this property

Here's a point:

This property must be declared in the element if you want to get the attribute of the element. Writing in CSS stylesheets and <style> is not available for scripting.

Also, Element.width and Element.style.width are two properties. Although the effect is the same, but Element.width is Number,element.style.width is a string

Get element Width height

    • Element.offsetwidth
    • Element.offsetheight

The offset property gets the width height of the element including padding, excluding margin

Element.style.width can only modify the value of a property and cannot be used to get a value

Get browser window width height

    • Window.innerwidth
    • Window.innerheight

    • Window.outerwidth
    • Window.outerheight

Scrolling properties

    • ScrollTop
    • ScrollLeft

Returns the full width and height of the element.

    • ScrollWidth
    • ScrollHeight

JavaScript DOM element height

Related Article

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.