Alibabacloud.com offers a wide variety of articles about documentelement clientwidth, easily find your documentelement clientwidth information here online.
Recently in the study of JavaScript, specifically bought a rhino horn book to see, more than 1000 pages, look at my dizzy brain up, turn to the DOM this chapter, suddenly remember the usual in the use of DOM, encountered a lot of this dom inside the various widths, height, deliberately write a write, write bad or write wrong, You are welcome to correct me. Well nonsense not much to say and begin to enter the subject.This article mainly discusses two points:A variety of width, height in domIi. co
the body, because IE, ff to padding, margin interpretation is not the same, so make clear that the treatment is not the following differences are not established.IE 1) If the upper layer of div is body, and there is a div between the div and the body, such as Body->div->divo;divo's Offsettop=div padding+margin+boder;2) If the upper layer of div is body, such as Body>divo;divo's Offsettop=div padding+margin+boder;This Divo offsettop=divo margin >body.padding is Divo margin, otherwise body.paddin
complete explanation of Scrollleft,scrollwidth,clientwidth,offsetwidth
ScrollHeight: Gets the scrolling height of the object.ScrollLeft: Sets or gets the left distance between the left edge of an object and the current visible content in the windowScrollTop: Sets or gets the distance between the top of the object and the topmost part of the visible content in the windowScrollWidth: Gets the scrolling width of the objectOffsetheight: Gets the height of
documentsEvent.clienty vertical coordinates of relative documentsEvent.offsetx horizontal coordinates relative to the containerEvent.offsety the vertical coordinate of the relative containerDocument.documentElement.scrollTop The vertical scrolling valueEvent.clientx+document.documentelement.scrolltop horizontal coordinates of relative documents + amount of vertical scrollingThe above mainly refers to IE, Firefox differences are as follows:IE6.0, ff1.06+:cli
A little research on obtaining the visible window size of various browsersIn my local test:It can be used in IE, Firefox, and operaDocument. Body. clientwidthDocument. Body. clientheightIt is very simple and convenient.In the company's projects:Opera is still in useDocument. Body. clientwidthDocument. Body. clientheightHowever, ie and Firefox useDocument.doc umentelement. clientwidthDocument.doc umentelement. clientheightIt turned out to be W3C standards.If you add this line of tag to the page,
ScrollWidthIt is the width of the actual content of the object. The width of the content in the object varies with the number of elements in the object. If the content is too large, the actual width of the object may be changed ).ClientWidthIt is the visible width of the object. If it is not set to the same side of the scroll bar, it will change with the display size of the window.OffsetWidthIs the visible width of the object. The package's scroll bar and other edges change with the display
ScrollWidth
Is the width of the actual content of the object, not the edge width, and how much the content in the object changes (the actual width of the object may vary).
ClientWidth
is the visible width of the object, not wrapping the edges of the scroll bar, and changing the size of the window's display.
Offsetwidth
is the visible width of the object, and the side lines, such as the package scroll bar, change with the display size of the window.
A
This. What are the differences between clientWidth and this. offsetWidth? offsetWidth includes the Border width. clientWidth is not included.
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Visible area width of the webpage: Document. Body. clientwidth
Visible area height: Document. Body. clientheight
Visible area width of the webpage: Document. Body. offsetwidth (including the width of the edge)
Visible area height of the webpage: Document. Body. offsetheight (including the width of the edge)
Webpage text width: Document. Body. scrollwidth
Webpage text height: Document. Body. scrollheight
The height of the page to be rolled: Document. B
ScrollHeight: gets the scroll height of an object.
ScrollLeft: sets or obtains the distance between the left-side border of the object and the leftmost end of the currently visible content in the window.
ScrollTop: sets or obtains the distance between the top of the object and the top of the visible content in the window.
ScrollWidth: gets the scroll width of an object.
OffsetHeight: gets the height of an object relative to the layout or the parent coordinate specified by the parent coordinate
1, offsetwidth the width of the current object2, offsetheight the height of the current object3. Offsetleft the distance from the current object to the left of its parent layer. It cannot be assigned a value. Set the distance to the left of the upper layer of the object, using the Style.left property.4. OffsetTop the distance from the top edge of the current object to its parent layer. it cannot be assigned. Set the distance of the object to the top edge of the upper layer with the Style.top pro
ScrollHeight: Gets the scrolling height of the object.
ScrollLeft: Sets or gets the left distance between the left edge of an object and the current visible content in the window
ScrollTop: Sets or gets the distance between the top of the object and the topmost part 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 pro
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 conten
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 settingstextarea{ border:5px solid red; width:200px; height:200px; padding:5px;}When the content
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 conten
the body, because IE, ff to padding, margin interpretation is not the same, so make clear that the treatment is not the following differences are not established.IE 1) If the upper layer of div is body, and there is a div between the div and the body, such as Body->div->divo;divo's Offsettop=div padding+margin+boder;2) If the upper layer of div is body, such as Body>divo;divo's Offsettop=div padding+margin+boder;This Divo offsettop=divo margin >body.padding is Divo margin, otherwise body.paddin
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.