aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/clientheight/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/element/clientheight/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/element/clientheight/index.html')
-rw-r--r--files/zh-cn/web/api/element/clientheight/index.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/clientheight/index.html b/files/zh-cn/web/api/element/clientheight/index.html
new file mode 100644
index 0000000000..b9cb7499ef
--- /dev/null
+++ b/files/zh-cn/web/api/element/clientheight/index.html
@@ -0,0 +1,62 @@
+---
+title: Element.clientHeight
+slug: Web/API/Element/clientHeight
+tags:
+ - Property
+translation_of: Web/API/Element/clientHeight
+---
+<p>{{ APIRef() }}</p>
+
+<p>这个属性是只读属性,对于没有定义CSS或者内联布局盒子的元素为0,否则,它是元素内部的高度(单位像素),包含内边距,但不包括水平滚动条、边框和外边距。</p>
+
+<p><code>clientHeight</code> 可以通过 CSS <code>height</code> + CSS <code>padding</code> - 水平滚动条高度 (如果存在)来计算.</p>
+
+<div class="note">
+<p><strong>备注:</strong> 此属性会将获取的值四舍五入取整数。 如果你需要小数结果, 请使用 {{ domxref("element.getBoundingClientRect()") }}.</p>
+
+<p>备注:上面的有问题 因为使用element.getBoundingClientRect()只能获取元素的width / height,但是这个值是 offsetWidth / offsetHeight ,包括边框的长度,所以不能获取clientWidth / clientHeight</p>
+</div>
+
+<h2 id=".E8.AF.AD.E6.B3.95.E5.92.8C.E5.80.BC" name=".E8.AF.AD.E6.B3.95.E5.92.8C.E5.80.BC">语法</h2>
+
+<pre class="eval">var <var>h</var> = <var>element</var>.clientHeight;
+</pre>
+
+<p>返回整数 <code><var>h</var></code>,表示 <code><var>element</var></code> 的 <code>clientHeight</code>(单位像素)。</p>
+
+<p><code>clientHeight</code> 是只读的.</p>
+
+<h2 id=".E8.8C.83.E4.BE.8B" name=".E8.8C.83.E4.BE.8B">示例</h2>
+
+<p><img alt="Image:Dimensions-client.png" src="https://developer.mozilla.org/@api/deki/files/185/=Dimensions-client.png"></p>
+
+<h2 id=".E8.A7.84.E8.8C.83" name=".E8.A7.84.E8.8C.83">规范</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-clientheight', 'clientheight')}}</td>
+ <td>{{Spec2('CSSOM View')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id=".E6.B3.A8.E6.84.8F" name=".E6.B3.A8.E6.84.8F">备注</h3>
+
+<p>clientHeight是在IE浏览器对象模型中引入的属性。</p>
+
+<h3 id=".E5.8F.82.E8.80.83" name=".E5.8F.82.E8.80.83">相关链接</h3>
+
+<ul>
+ <li>{{domxref("HTMLElement.offsetHeight")}}</li>
+ <li>{{domxref("Element.scrollHeight")}}</li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Determining_the_dimensions_of_elements">Determining the dimensions of elements</a></li>
+</ul>