diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlelement/offsetparent/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlelement/offsetparent/index.html')
-rw-r--r-- | files/zh-cn/web/api/htmlelement/offsetparent/index.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlelement/offsetparent/index.html b/files/zh-cn/web/api/htmlelement/offsetparent/index.html new file mode 100644 index 0000000000..4592a236ef --- /dev/null +++ b/files/zh-cn/web/api/htmlelement/offsetparent/index.html @@ -0,0 +1,48 @@ +--- +title: HTMLElement.offsetParent +slug: Web/API/HTMLElement/offsetParent +translation_of: Web/API/HTMLElement/offsetParent +--- +<div>{{APIRef}}</div> + +<p><strong><code>HTMLElement.offsetParent</code></strong> 是一个只读属性,返回一个指向最近的(指包含层级上的最近)包含该元素的定位元素或者最近的 <code>table,</code><code>td,</code><code>th,</code><code>body</code>元素。当元素的 <code>style.display</code> 设置为 "none" 时,<code>offsetParent</code> 返回 <code>null</code>。<code>offsetParent</code> 很有用,因为 {{domxref("HTMLElement.offsetTop","offsetTop")}} 和 {{domxref("HTMLElement.offsetLeft","offsetLeft")}} 都是相对于其内边距边界的。</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="syntaxbox"><var>parentObj</var> = element.offsetParent; +</pre> + +<ul> + <li><var>parentObj</var> 是一个对象引用,当前元素相对于该对象偏移(offset)。</li> +</ul> + +<h2 id="Compatibility" name="Compatibility">浏览器兼容性</h2> + +<p>在 Webkit 中,如果元素为隐藏的(该元素或其祖先元素的 <code>style.display</code> 为 "none"),或者该元素的 <code>style.position</code> 被设为 "fixed",则该属性返回 <code>null</code>。</p> + +<p>在 IE 9 中,如果该元素的 <code>style.position</code> 被设置为 "fixed",则该属性返回 <code>null</code>。(<code>display:none</code> 无影响。)</p> + +<h2 id="Specification" name="Specification">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('CSSOM View', '#dom-htmlelement-offsetparent', 'offsetParent')}}</td> + <td>{{Spec2('CSSOM View')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Compatibility" name="Compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.HTMLElement.offsetParent")}}</p> |