aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlelement/offsetheight/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlelement/offsetheight/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlelement/offsetheight/index.html')
-rw-r--r--files/zh-cn/web/api/htmlelement/offsetheight/index.html80
1 files changed, 80 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlelement/offsetheight/index.html b/files/zh-cn/web/api/htmlelement/offsetheight/index.html
new file mode 100644
index 0000000000..0f852a4689
--- /dev/null
+++ b/files/zh-cn/web/api/htmlelement/offsetheight/index.html
@@ -0,0 +1,80 @@
+---
+title: HTMLElement.offsetHeight
+slug: Web/API/HTMLElement/offsetHeight
+tags:
+ - API
+ - CSSOM View
+ - NeedsMarkupWork
+ - NeedsNonDHMLImage
+ - Property
+ - Reference
+ - 属性
+translation_of: Web/API/HTMLElement/offsetHeight
+---
+<div>{{ APIRef("HTML DOM") }}</div>
+
+<p> <strong><code>HTMLElement.offsetHeight</code></strong> 是一个只读属性,它返回该元素的像素高度,高度包含该元素的垂直内边距和边框,且是一个整数。</p>
+
+<p><span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">通常,元素的offsetHeight是一种元素CSS高度的衡量标准,包括元素的边框、内边距和元素的水平滚动条(如果存在且渲染的话),不包含:before或:after等伪类元素的高度。</span></p>
+
+<p><span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">对于文档的body对象,它包括代替元素的CSS高度线性总含量高。</span>浮动元素的向下延伸内容高度是被忽略的。 </p>
+
+<p>如果元素被隐藏(例如 元素或者元素的祖先之一的元素的style.display被设置为none),则返回0</p>
+
+<div class="note">
+<p>这个属性值会被四舍五入为整数值,如果你需要一个浮点数值,请用 {{ domxref("element.getBoundingClientRect()") }}.</p>
+</div>
+
+<h2 id="Syntax_and_values" name="Syntax_and_values">语法</h2>
+
+<pre class="eval">var <em>intElemOffsetHeight</em> = document.getElementById(<em>id_attribute_value</em>).offsetHeight;
+</pre>
+
+<p><em>intElemOffsetHeight</em><span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">是一个变量存储对应元素的</span>offsetHeight<span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">像素的整数值。</span>offsetHeight<span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">属性是只读的。</span></p>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<p><img alt="Image:Dimensions-offset.png" src="https://developer.mozilla.org/@api/deki/files/186/=Dimensions-offset.png"></p>
+
+<p>上面的图片中显示了scollbar和窗口高度的offsetHeight.但是不能滚动的元素可能会有一个很大的高度值,大于可以看见的内容。这些元素原则上是被包含在滚动元素之中的。所以,这些不能滚动的元素可能会因为scrollTop的值会被完全隐藏或者部分隐藏;</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-offsetHeight', 'offsetLeft')}}</td>
+ <td>{{Spec2('CSSOM View')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Notes" name="Notes">备注</h3>
+
+<p><span style="font-family: Consolas,Monaco,'Andale Mono',monospace;">offsetHeight 是一个DOM属性,由MSIE首次提出。</span><span style="background-color: #fbfcfe; color: #333333; font-family: arial; line-height: 24px;">它有时被称为一个元素的物理/图形的尺寸,或是一个元素的边界框(border-box)的高度。</span></p>
+
+<h2 id="See_Also" name="See_Also">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>此页面上的兼容性表是根据结构化数据生成的。如果您想贡献数据,请查看https://github.com/mdn/browser-compat-data并向我们发送请求请求。</p>
+</div>
+
+<p>{{Compat("api.HTMLElement.offsetHeight")}}</p>
+
+<h2 id="See_Also" name="See_Also">相关链接</h2>
+
+<ul>
+ <li>{{domxref("Element.clientHeight")}}</li>
+ <li>{{domxref("Element.scrollHeight")}}</li>
+ <li>{{domxref("HTMLElement.offsetWidth")}}</li>
+ <li><a href="/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements" title="en/Determining_the_dimensions_of_elements">Determining the dimensions of elements</a> 如何选择(计算)元素占用的空间</li>
+ <li><a href="https://docs.microsoft.com/en-us/previous-versions//hh781509(v=vs.85)">MSDN Measuring Element Dimension and Location</a></li>
+</ul>