免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2015年5月27日 星期三

html element scrollWidth, clientWidth , scrollbar width


scrollWidth(including non-viewable part) 與 clientWidth (only viewable part) 的差異在於 "viewable" or not

//=== http://www.w3schools.com/jsref/prop_element_scrollwidth.asp
"""...
The scrollWidth property returns the entire width of an element in pixels, including padding, but not the border, scrollbar or margin.

...
The scrollWidth and scrollHeight properties return the entire height and width of an element, including the height and width that is not viewable (because of overflow).



..."""


//=== http://www.w3schools.com/jsref/prop_element_clientwidth.asp

clientWidth
"""...
The clientWidth property returns the viewable height of an element
in pixels, including padding, but not the border, scrollbar or margin.
..."""




//=== https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth
"""...
The Element.scrollWidth read–only property returns either the width in pixels of the content of an element or the width of the element itself, whichever is greater. If the element is wider than its content area (for example, if there are scroll bars for scrolling through the content), the scrollWidth is larger than the clientWidth.

This property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect().

..."""



//=== scrollbar width

http://stackoverflow.com/questions/19172936/javascript-get-window-width-minus-scrollbar-width

"""...
the scrollbar is a feature of the browser and not the web page self.
Measurement should be done dynamically.
A measurement with a scrollbar and a measurement without a scrollbar
will resolve into calculating the difference in width.

..."""

the width of the scrollbar is not standard and
varies from system to system and browser to browser





沒有留言:

張貼留言