aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/cssstyledeclaration/length/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/cssstyledeclaration/length/index.html')
-rw-r--r--files/zh-cn/web/api/cssstyledeclaration/length/index.html108
1 files changed, 108 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstyledeclaration/length/index.html b/files/zh-cn/web/api/cssstyledeclaration/length/index.html
new file mode 100644
index 0000000000..4075f9f4a4
--- /dev/null
+++ b/files/zh-cn/web/api/cssstyledeclaration/length/index.html
@@ -0,0 +1,108 @@
+---
+title: CSSStyleDeclaration.length
+slug: Web/API/CSSStyleDeclaration/length
+translation_of: Web/API/CSSStyleDeclaration/length
+---
+<p>{{ APIRef("CSSOM") }}</p>
+
+<p>这是一个只读的属性,它返回一个指定元素声明过的样式个数</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var <em>num</em> = <em>styles</em>.length;</pre>
+
+<h3 id="值">值</h3>
+
+<p>指定元素上明确声明过的样式属性个数.</p>
+
+<h2 id="示例">示例</h2>
+
+<p>获取下面HTML元素明确设置过的属性个数:</p>
+
+<pre class="brush: html">&lt;div id="div1" style="margin: 0 10px; background-color: #CA1; font-family: monospace"&gt;&lt;/div&gt;</pre>
+
+<p>JavaScript代码:</p>
+
+<pre>var myDiv = document.getElementById('div1'); var divStyle = myDiv.style; var len = divStyle.length; // 6</pre>
+
+<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', '#dom-cssstyledeclaration-length', 'CSSStyleDeclaration.length')}}</td>
+ <td>工作草案</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}}</td>
+ <td>废弃</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<p><strong>浏览器兼容性</strong></p>
+
+<p>兼容性列表</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <thead>
+ <tr>
+ <th scope="col">特性</th>
+ <th scope="col">Chrome</th>
+ <th scope="col">Edge</th>
+ <th scope="col">Firefox (Gecko)</th>
+ <th scope="col">Internet Explorer</th>
+ <th scope="col">Opera</th>
+ <th scope="col">Safari (WebKit)</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>基础支持</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>基础支持</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>