aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/@property/initial-value
diff options
context:
space:
mode:
authorMars Yao <marswiz@yeah.net>2021-03-16 01:40:33 +0800
committerGitHub <noreply@github.com>2021-03-16 01:40:33 +0800
commit9f4ae674a3f256e637b6539363f76a323e96f20c (patch)
treef7c238ade846db07205dfaffe8a041100d3bed07 /files/zh-cn/web/css/@property/initial-value
parent5c428c5d35af49a94703338caa9e05e960c01ac6 (diff)
downloadtranslated-content-9f4ae674a3f256e637b6539363f76a323e96f20c.tar.gz
translated-content-9f4ae674a3f256e637b6539363f76a323e96f20c.tar.bz2
translated-content-9f4ae674a3f256e637b6539363f76a323e96f20c.zip
Add and translate pages about @property. (#171)
* 'add_@property_contents'
Diffstat (limited to 'files/zh-cn/web/css/@property/initial-value')
-rw-r--r--files/zh-cn/web/css/@property/initial-value/index.html101
1 files changed, 101 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/@property/initial-value/index.html b/files/zh-cn/web/css/@property/initial-value/index.html
new file mode 100644
index 0000000000..61363a59fb
--- /dev/null
+++ b/files/zh-cn/web/css/@property/initial-value/index.html
@@ -0,0 +1,101 @@
+---
+title: '初始值'
+slug: Web/CSS/@property/initial-value
+tags:
+ - CSS
+ - Reference
+ - Web
+ - Property
+ - Houdini
+---
+
+<div>{{CSSRef}}{{SeeCompatTable}}</div>
+
+<p><strong><code>initial-value</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a>描述符在使用{{cssxref("@property")}} {{cssxref("at-rule")}}的时候是必需的,除非syntax属性接受了任何有效的token流。 它为属性设置初始值。</p>
+
+<p>被选定为<code>initial-value</code>的参数,依照<code>syntax</code>描述符定义,必须可以正确地解析。 因此,如果<code>syntax</code>描述符为<code>&lt;color&gt;</code>,那么初始值必须是一个有效的{{cssxref("color")}}值。</p>
+
+<h2 id="Syntax">语法</h2>
+
+<pre class="brush: css no-line-numbers">@property --property-name {
+ syntax: '&lt;color&gt;';
+ inherits: false;
+ initial-value: #c0ffee;
+}
+
+@property --property-name {
+ syntax: '&lt;color&gt;';
+ inherits: true;
+ initial-value: #c0ffee;
+}</pre>
+
+<h2 id="Values">取值</h2>
+
+<p>对于设定的<code>syntax</code>,具有正确值的字符串。</p>
+
+<h2 id="Formal_definition">标准定义</h2>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Formal_syntax">标准语法</h2>
+
+<pre class="brush: css">{{csssyntax}}</pre>
+
+<h2 id="Examples">实例</h2>
+
+<p>为 <code>--my-color</code> {{cssxref('--*', '自定义属性')}}添加颜色值类型检测、设置默认值并且设置属性值不允许被继承。</p>
+
+<p>使用 <a href="/en-US/docs/Web/CSS">CSS</a> {{cssxref('@property')}} <a href="/en-US/docs/Web/CSS/At-rule">规则</a>:</p>
+
+<pre class="brush: css">@property --my-color {
+ syntax: '&lt;color&gt;';
+ inherits: false;
+ initial-value: #c0ffee;
+}
+</pre>
+
+<p>使用 <a href="/en-US/docs/Web/JavaScript">JavaScript中的</a> {{domxref('CSS.registerProperty')}}函数:</p>
+
+<pre class="brush: js">window.CSS.registerProperty({
+ name: '--my-color',
+ syntax: '&lt;color&gt;',
+ inherits: false,
+ initialValue: '#c0ffee',
+});
+</pre>
+
+<h2 id="Formal_syntax">标准语法</h2>
+
+<pre class="brush: css">{{csssyntax}}</pre>
+
+<h2 id="Specifications">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">提案</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS Properties and Values API', '#at-property-rule')}}</td>
+ <td>{{Spec2('CSS Properties and Values API')}}</td>
+ <td>初始定义.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">浏览器兼容性</h2>
+
+<div class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div>
+
+<p>{{Compat("css.at-rules.property")}}</p>
+
+<h2 id="See_also">另见</h2>
+
+<ul>
+ <li><a href="/zh-CN/docs/Web/API/CSS_Properties_and_Values_API">CSS属性与值 API</a></li>
+ <li><a href="/zh-CN/docs/Web/API/CSS_Painting_API">CSS 绘图 API</a></li>
+ <li><a href="/zh-CN/docs/Web/API/CSS_Typed_OM_API">CSS 类型对象模型</a></li>
+ <li><a href="/zh-CN/docs/Web/Houdini">CSS Houdini</a></li>
+</ul>