aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/computed_value
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/css/computed_value
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/css/computed_value')
-rw-r--r--files/zh-cn/web/css/computed_value/index.html50
1 files changed, 50 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/computed_value/index.html b/files/zh-cn/web/css/computed_value/index.html
new file mode 100644
index 0000000000..a281cf0b1d
--- /dev/null
+++ b/files/zh-cn/web/css/computed_value/index.html
@@ -0,0 +1,50 @@
+---
+title: 计算值
+slug: Web/CSS/computed_value
+tags:
+ - CSS
+ - Reference
+translation_of: Web/CSS/computed_value
+---
+<p>{{cssref}}</p>
+
+<p>一个CSS属性的计算值是指这个属性在由父类转向子类的继承中的值。它通过指定值计算出来:</p>
+
+<ul>
+ <li>处理特殊的值 {{cssxref("inherit")}},{{cssxref("initial")}}, {{cssxref("unset")}}和 {{cssxref("revert")}}。</li>
+ <li>进行计算,以达到属性摘要中“计算值”行中描述的值。</li>
+</ul>
+
+<p>计算值所需要的计算通常包括将相对值转换成绝对值(如<span> em </span><span>单位或百分比)。</span>例如,如一个元素的属性值为<code> font-size:16px </code>和<code> padding-top:2em</code>, 则<code> padding-top </code><font face="Open Sans, sans-serif">的计算值为 </font><code>32px </code>(字体大小的2倍).</p>
+
+<p>然而,对于有些属性(这些元素的百分比与需要布局确定后才能知道的值有关,如<code> width</code>,<code> margin-right</code>,<code> text-indent</code>, 和<code> top</code>),它们的“百分比值”会转换成“百分比的计算值”。另外,<span>line-height </span><span>属性值如是没有单位的数字,则该值就是其计算值。这些计算值中的相对值会在</span><span> </span><a href="/en-US/docs/CSS/used_value" title="en/CSS/used_value">应用值</a><span> 确定后转换成绝对值。</span></p>
+
+<div class="note">
+<p>注意:{{domxref("Window.getComputedStyle", "getComputedStyle()")}} DOM API 返回 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/resolved_value">resolved value</a>, 可能是 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/computed_value">computed value</a> 或 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/used_value">used value</a>其中的一个,取决于属性。</p>
+</div>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">版本</th>
+ <th scope="col">评论</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("CSS2.1", "cascade.html#computed-value", "computed value")}}</td>
+ <td>{{Spec2("CSS2.1")}}</td>
+ <td>初始规范</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="相关" style="line-height: 30px; font-size: 2.14285714285714rem;">相关</h2>
+
+<ul>
+ <li>{{domxref("window.getComputedStyle")}}</li>
+ <li>{{CSS_key_concepts}}</li>
+</ul>