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的大小。
相关文章推荐
- Web布局连载——两栏固定布局(五)
- [div+css]晒晒最新制作专题推广页模板
- 盒子模型
- CSS选择器
- CSS样式优先权
- [css] line-height 百分比单位和数值单位的区别
- Apple官网研究之使用Justify布局导航
- 关于前端的思考与感悟
- rem : web app适配的秘密武器
- jquery高级应用之Deferred对象
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表
- 10条影响CSS渲染速度的写法与使用建议第1/3页
- BS项目中的CSS架构_仅加载自己需要的CSS
- 很不错的 CSS Hack 又学了一招
- 发一个css比较清爽的写法
- CSS expression控制图片自动缩放效果代码[兼容 IE,Firefox]
- css布局网页水平居中常用方法
- CSS经典技巧十则第1/2页