Layout Properties And Methods In Element, HTMLElement And Window
2018-02-12 17:32
513 查看
Inheritance Graph
EventTarget <- Node <- Element <- HTMLElement
Layout Properties And Methods In Element
Element.clientTop: read-only property returns the width of the top border of an element in pixels.
Element.clientLeft: read-only property returns the width of the left border of an element in pixels.
Elment.clientHeight: read-only property returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin. ClientHeight can be calculated as CSS height + CSS padding - height of horizontal scrollbar (if present). Otherwise it will return zero if the element has no CSS or inline layout boxes. If the content is overflow and the scrollbar presents,
clientHeightwill be the height of the visible content.
Element.clientWidth: similar to
clientHeight, but it represent the inner width of the element.
Element.scrollTop: the property gets or sets the number of pixels that an element’s content is scrolled vertically. An element’s
scrollTopvalue is a measurement of the distance from the element’s top to its topmost visible content. When an element’s content does not generate a vertical scrollbar, then its
scrollTopvalue is 0.
scrollTopcan be set to any integer value, with certain caveats: First, if the element can’t be scrolled (e.g. it has no overflow or if the element has a property of “non-scrollable”),
scrollTopis 0. Second,
scrollTopdoesn’t respond to negative values; instead, it sets itself back to 0. Third, if set to a value greater than the maximum available for the element,
scrollTopsettles itself to the maximum value.
Element.scrollLeft: similar to
scrollTop, but it represent the number of pixels of the element scrolled to the left.
Element.scrollHeight: read-only property returns the height of an element’s content, including content not visible on the screen due to overflow. If the element’s content can fit without a need for vertical scrollbar, its
scrollHeightis equal to
clientHeight.
Element.scrollWidth: similar to
scrollHeight.
Element.getClientRects(): returns a collection of
DOMRectobjects that indicate the bounding rectangles for each CSS border box in a client.
Element.getBoundingClientRect(): returns the size of an element and its position relative to the viewport. The returned value is a
DOMRectobject.
DOMRectis an object containing
top,
left,
right,
bottom,
x(not supported by IE),
y(not supported by IE),
width(supported by IE 9+),
height(supported by IE 9+) properties.
top,
left,
rightand
bottomproperties are the distances relative to the top-left corner of the viewport.
heightand
widthare almost equal to
HTMLElement.offsetHeightand
HTMLElement.offsetWidth..
Layout Properties In HTMLElement
HTMLElement.offsetParent: read-only property returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. Returns null when the element has
style.displayset to “none”. The
offsetParentis useful because
offsetTopand
offsetLeftare relative to its padding edge.
HTMLElement.offsetTop: read-only property returns the distance of the current element relative to the top of the
offsetParentnode.
HTMLElement.offsetLeft: read-only property returns the number of pixels that the upper left corner of the current element is offset to the left within the
HTMLElement.offsetParentnode.
HTMLElement.offsetHeight: read-only property is the height of the element including vertical padding and borders, as an integer.
HTMLElement.offsetWidth: read-only property returns the layout width of an element. Typically, an element’s
offsetWidthis a measurement which includes the element borders, the element horizontal padding, the element vertical scrollbar (if present, if rendered) and the element CSS width. If the element is hidden (for example, by style.display on the element or one of its ancestors to “none”), then 0 is returned.
Layout Properties And Methods In window
window.scrollY(window.pageYOffset): returns the number of pixels that the document is currently scrolled vertically.
window.scrollX(window.pageXOffset): returns the number of pixels that the document is currently scrolled horizontally.
window.scrollTo(x, y)(window.scroll(x, y): scrolls to a particular set of coordinates in the document.
window.scrollBy(offsetX, offsetY): scrolls the document in the window by the given amount.
相关文章推荐
- Methods GET and POST in HTML forms - what's the difference?
- Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a br
- HTML DOM Properties and Methods
- Xrm.Page.data.entity Properties and Methods
- Don’t Use Accessor Methods in Initializer Methods and dealloc 【初始化和dealloc方法中不要调用属性的存取方法,而要直接调用 _实例变量】
- RenderBody, RenderPage and RenderSection methods in MVC 3
- RenderBody, RenderPage and RenderSection methods in MVC 3
- window、document、html、body、element的事件属性比较
- java 提示----This element has no attached source and the Javadoc could not be found in the attached Javadoc
- [Android] Different between Padding and Margin in Layout
- ALV in a Pop up window and ALV in a dialog box
- Find the Minimum Element in A sorted and Rotated Array
- OOP in JS Public/Private Variables and Methods
- Math object's properties and methods
- Difference between event.target and event.currentTarget properties in an event object.
- JavaScript Patterns 5.3 Private Properties and Methods
- it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element
- Divide and Conquer:215. Kth Largest Element in an Array
- [LeetCode] 34. Search for a Range 搜索一个范围(Find First and Last Position of Element in Sorted Array)
- pansharping文献:《A survey of classical methods and newtrends in pansharpening of multipectral images》