aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/clientwidth/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/element/clientwidth/index.html')
-rw-r--r--files/zh-cn/web/api/element/clientwidth/index.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/clientwidth/index.html b/files/zh-cn/web/api/element/clientwidth/index.html
new file mode 100644
index 0000000000..562a9e1ad5
--- /dev/null
+++ b/files/zh-cn/web/api/element/clientwidth/index.html
@@ -0,0 +1,66 @@
+---
+title: Element.clientWidth
+slug: Web/API/Element/clientWidth
+tags:
+ - API
+ - 参考
+ - 属性
+translation_of: Web/API/Element/clientWidth
+---
+<div>{{APIRef("DOM")}}</div>
+
+<p>内联元素以及没有 CSS 样式的元素的 <code><strong>clientWidth</strong></code> 属性值为 0。<code><strong>Element.clientWidth</strong></code> 属性表示元素的内部宽度,以像素计。该属性包括内边距 padding,但不包括边框 border、外边距 margin 和垂直滚动条(如果有的话)。</p>
+
+<p>当在根元素(&lt;html&gt;元素)上使用clientWidth时(或者在&lt;body&gt;上,如果文档是在quirks(怪异)模式下),将返回viewport的宽度(不包括任何滚动条). <a href="https://www.w3.org/TR/2016/WD-cssom-view-1-20160317/#dom-element-clientwidth">This is a special case of <code>clientWidth</code></a>.</p>
+
+<div class="note">
+<p>该属性值会被四舍五入为一个整数。如果你需要一个小数值,可使用 {{ domxref("element.getBoundingClientRect()") }}。</p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var <var>intElemClientWidth</var> = <var>element</var>.clientWidth;
+</pre>
+
+<p><code><var>intElemClientWidth</var></code> 是一个整数,表示元素的 <code>clientWidth</code>。<code>clientWidth</code> 是一个只读属性。</p>
+
+<h2 id="示例">示例</h2>
+
+<p><img alt="Image:Dimensions-client.png" class="internal" src="/@api/deki/files/185/=Dimensions-client.png"></p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSSOM View', '#dom-element-clientwidth', 'clientWidth')}}</td>
+ <td>{{Spec2("CSSOM View")}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="备注">备注</h3>
+
+<p><code>clientWidth</code> 首次出现于微软 IE 早期的 DHTML 对象模型中。</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Element.clientWidth")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("HTMLElement.offsetWidth")}}</li>
+ <li>{{domxref("Element.scrollWidth")}}</li>
+ <li><a href="/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements">Determining the dimensions of elements</a></li>
+</ul>