css-offsetParent翻译
对offsetParent的翻译
来源:http://www.w3.org/TR/cssom-view/#dom-htmlelement-offsetparent
offsetParent的属性返回值计算遵循以下步骤:
1、 If any of the following holds true return null and terminate this algorithm:
如果该元素满足以下任意一个,则element.offSetParent 返回null,终止该算法
- The element does not have an associated CSS layout box.
- 该元素没有相关的CSS布局box
- The element is the root element.
- 该元素是根元素(html)
- The element is the HTML body element.
- 该元素是HTML body元素
- The element's computed value of the 'position' property is 'fixed'.
- 该元素的position为"fixed"
2、Return the nearest ancestor element of the element for which at least one of the following is true and terminate this algorithm if such an ancestor is found:
返回最近的一个祖先元素。祖先元素满足以下条件的至少一条,同时如果找到这样的元素,终止该算法。
-
The computed value of the 'position' property is not 'static'.
该元素position的值不是"static" -
It is the HTML body element.
该元素是body元素 -
The computed value of the 'position' property of the element is 'static' and the ancestor is one of the following HTML elements: td, th, or table.
该元素的position属性所得值为static,同时这个元素是以下元素之一:td,th,table
3、Return null.
返回null
The offsetTop attribute must return the result of running these steps:
1、If the element is the HTML body element or does not have any associated CSS layout box return zero and terminate this algorithm.
如果该元素是html的body元素,或者没有相关的CSS layout box,则返回zero,终止该算法
2、If the offsetParent of the element is null return the y-coordinate of the top border edge of the first CSS layout box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors, and terminate this algorithm.
如果该元素的offsetParent是null,返回该元素的的top border edge到相关的css 布局盒子的y坐标。与最初包含原始block相关,忽略任何应用到其元素上面的transforms和他的祖先。终止该算法。
Return the result of subtracting the y-coordinate of the top padding edge of the first CSS layout box associated with the offsetParent of the element from the y-coordinate of the top border edge of the first CSS layout box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors.
返回offsetParent元素相关联的第一个css布局盒子top padding edge的y坐标,减去该元素相关联的第一个css布局盒子的top border edge 的y坐标。与最初包含原始block相关,忽略任何应用到其元素上面的transforms和他的祖先。终止该算法。
An inline element that consists of multiple line boxes will only have its first CSS layout box considered.
一个由多个内联盒子组成的内联元素将只会考虑它的第一个css 布局盒子
The offsetLeft attribute must return the result of running these steps:
未完待续