About the understanding of clientwidth scrollwidth offsetwidth

Source: Internet
Author: User

  • ClientWidth: Width of element visible area clientwidth=padding+width-scroll bar
  • ScrollWidth: The width of the actual content of the element scrollwidth=padding+width (the actual content of the element)
  • Offsetwidth: Height of element visible area + border offsetwidth=border+width+padding

Code settings

textarea{
border:5px solid red;
width:200px;
height:200px;
padding:5px;
}
When the content is not beyond the viewable area
Clientwidth=5+200+5
Scrollwidth=5+200+5
Offsetwidth=5+5+200+5+5

When the content is outside the viewable area
        Clientwidth=5+200+5
scrollwidth=5+ Actual width +5
Offsetwidth=5+5+200+5+5

The problems encountered in the practice

does not add <! to the top of the document DOCTYPE html>

TextArea is set by the browser as the default property has the Box-sizing:border-box property, the width of the high is fixed padding and border are included in the width of the




About the understanding of clientwidth scrollwidth offsetwidth

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.