您的位置:首页 > Web前端 > CSS

CSSOM View Module

2016-06-16 11:43 381 查看

CSS Object Model 视图模式

最近详细学习了一下CSSOM视图模式,主要是想弄明白client, scroll, offset等一些属性的定义和用法,根据目前的理解先记录下来,以后有新的领悟再继续更新。

主要学习地址:w3网站(https://www.w3.org/TR/cssom-view-1/)、W3schools(http://www.w3schools.com/jsref/dom_obj_all.asp)

CSSOM视图模式提供了一些API,用于检测和处理文档的可视化视图,主要包括以下几个方面:

获取元素的盒子布局在文档中的位置;

通过script获取可视区(viewport)的宽度;

元素滚动特性

Window视图属性

innerWidth & innerHeight

The width/height of the viewport, including the size of a rendered scrollbar.
可视区的宽高,包括滚动条的大小。


outerWidth & outerHeight

The width/height of the client window.
浏览窗口的宽高。


scrollX & scrollY

X-coordinate/Y-coordinate, relative to the initial containing block origin, of left/top of the viewport.
相对于初始包含块的起始位置可视区滚动的X坐标和Y坐标值。


pageXOffset & pageYOffset

Same with the value returned by scrollX/scrollY
与scrollX和scrollY的返回值相同。


screenX & screenY

X-coordinate/Y-coordinate, relative to the origin of the screen of the output device, of the left/top of the client window.
用户浏览窗口相对于输出设备的X/Y坐标值。


兼容性:IE9+, FF3.0+, Saf4.0+, Chrome4+

screen interface

availWidth & availHeight

The available width/height of the rendering surface of the output device, excluding the taskbar.
输出设备的可渲染窗口宽高,不包括任务栏大小。
兼容性:IE5.5+, FF3.0+, Saf4.0+, Chrome4+


width & height

The width/height of the output device.
输出设备的宽高。
兼容性:IE5.5+, FF3.0+, Saf4.0+, Chrome4+


colorDepth

24
显示器的颜色深度。
兼容性:IE5.5+, FF3.0+, Saf4.0+, Chrome4+


pixelDepth

24
与colorDepth相同。
兼容性:IE9+, FF3.0+, Saf4.0+, Chome4+


HTML DOM Element

scrollTop & scrollLeft

Y-coordinate/X-coordinate of the scrolling area.
元素滚动区域的大小,可读写。
兼容性:IE5.5+, FF3.0+, Saf 4.0+, Chome4+


scrollWidth & scrollHeight

The width/height of an element, including padding.
包含padding值的元素宽高。
兼容性:IE8+, FF3.0+, Saf4.0+, Chrome4+


clientTop & clientLeft

The width of the top/left border of an element.
元素的上/左边距的宽度。
兼容性:IE5.5+, FF3.0+, Saf 4.0+, Chome4+


clientWidth & clientHeight

The width/height of an element, including padding.
与scrollWidth/scrollHeight返回值相同。
兼容性:IE5.5+, FF3.0+, Saf 4.0+, Chome4+


以下三个属性的兼容性:IE5.5+, FF3.0+, Saf 4.0+, Chome4+

offsetParent

The nearest ancestor that has a position other than static.
最近的一个祖先元素,其position属性值不是static。用来计算offsetLeft和offsetTop的值。


offsetTop & offsetLeft

The vertical/horizontal offset position of an element, relative to offsetParent.
offsetTop/offsetLeft = the top/left position, margin of the element + the top/left padding, scrollbar and border of the offsetParent element.
元素垂直/水平方向距离其祖先元素的长度。


offsetWidth & offsetHeight

The width/height of an element, including padding, border and scrollbar.
元素的宽/高,包括padding大小,border大小和scrollbar的大小。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  CSSOM client offset scroll css