diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/custom-ident/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/custom-ident/index.html')
-rw-r--r-- | files/zh-cn/web/css/custom-ident/index.html | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/custom-ident/index.html b/files/zh-cn/web/css/custom-ident/index.html new file mode 100644 index 0000000000..09712f52e9 --- /dev/null +++ b/files/zh-cn/web/css/custom-ident/index.html @@ -0,0 +1,119 @@ +--- +title: <custom-ident> +slug: Web/CSS/custom-ident +tags: + - CSS + - CSS数据类型 +translation_of: Web/CSS/custom-ident +--- +<div>{{CSSRef}}</div> + +<p><strong><code><custom-ident></code> </strong>指用户自定义字符串标识符。一种<a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">数据类型</a>;要区分大小写,值不能有任何歧义。</p> + +<h2 id="语法">语法</h2> + +<p><code><custom-ident></code> 语法同CSS属性名相似,但它是区分大小写的。可以由以下字符组成:</p> + +<ul> + <li>字母 (<code>A</code> - <code>Z</code>, <code>a</code> - <code>z</code>),</li> + <li>十进制数 (<code>0</code> - <code>9</code>),</li> + <li>连字符 (<code>-</code>),</li> + <li>下划线 (<code>_</code>),</li> + <li>转义字符 ( <code>\</code>),</li> + <li><a class="external" href="http://en.wikipedia.org/wiki/Unicode">Unicode</a> 编码(格式:转义字符(<code>\</code>)后跟1到6位十六进制数)</li> +</ul> + +<p>注意:<code>id1</code>, <code>Id1</code>, <code>iD1</code>和<code>ID1</code>都是不同标识符,因为标识符是区分大小写的。另一方面,因为可以解码,所以 <code>toto\?</code> 和 <code>toto\3F</code> 是相同的。</p> + +<h3 id="禁用值">禁用值</h3> + +<p><code><custom-ident></code> 不能用单引号或双引号包起来。此外,第一个字符不能为数字,字符串开头不能是连字符 (<code>-</code>) 后跟数字或连字符。</p> + +<p>为避免歧义,各个属性对应的<code><custom-ident></code> 禁止使用以下特殊值:</p> + +<dl> + <dt>{{cssxref("animation-name")}}</dt> + <dd>禁用CSS关键字 <code>unset</code>, <code>initial</code>, <code>inherit</code>, <code>none</code></dd> + <dt>{{cssxref("counter-reset")}}</dt> + <dt>{{cssxref("counter-increment")}}</dt> + <dd>禁止使用<code>unset</code>, <code>initial</code>, <code>inherit</code>, <code>none</code>.</dd> + <dt>{{cssxref("@counter-style")}}</dt> + <dt>{{cssxref("list-style-type")}}</dt> + <dd>禁止使用<code>unset</code>, <code>initial</code>, <code>inherit</code>, <code>none</code>, <code>inline</code>, <code>outside</code>. 同时不同浏览器预定义的值如: <code>disc</code>, <code>circle</code>, <code>square</code>, <code>decimal</code>, <code>cjk-decimal</code>, <code>decimal-leading-zero</code>, <code>lower-roman</code>, <code>upper-roman</code>, <code>lower-greek</code>, <code>lower-alpha</code>, <code>lower-latin</code>, <code>upper-alpha</code>, <code>upper-latin</code>, <code>arabic-indic</code>, <code>armenian</code>, <code>bengali</code>, <code>cambodian</code>, <code>cjk-earthly-branch</code>, <code>cjk-heavenly-stem</code>, <code>cjk-ideographic</code>, <code>devanagari</code>, <code>ethiopic-numeric</code>, <code>georgian</code>, <code>gujarati</code>, <code>gurmukhi</code>, <code>hebrew</code>, <code>hiragana</code>, <code>hiragana-iroha</code>, <code>japanese-formal</code>, <code>japanese-informal</code>, <code>kannada</code>, <code>katakana</code>, <code>katakana-iroha</code>, <code>khmer</code>, <code>korean-hangul-formal</code>, <code>korean-hanja-formal</code>, <code>korean-hanja-informal</code>, <code>lao</code>, <code>lower-armenian</code>, <code>malayalam</code>, <code>mongolian</code>, <code>myanmar</code>, <code>oriya</code>, <code>persian</code>, <code>simp-chinese-formal</code>, <code>simp-chinese-informal</code>, <code>tamil</code>, <code>telugu</code>, <code>thai</code>, <code>tibetan</code>, <code>trad-chinese-formal</code>, <code>trad-chinese-informal</code>, <code>upper-armenian</code>, <code>disclosure-open</code>, 和 <code>disclosure-close</code>也不能使用。</dd> + <dt>{{cssxref("grid-row-start")}}<br> + {{cssxref("grid-row-end")}}<br> + {{cssxref("grid-column-start")}}<br> + {{cssxref("grid-column-end")}}</dt> + <dd>禁止使用 <code>span</code> 。</dd> + <dt>{{cssxref("will-change")}}</dt> + <dd>禁止使用<code>unset</code>, <code>initial</code>, <code>inherit</code>, 以及 <code>will-change</code>, <code>auto</code>, <code>scroll-position</code>, and <code>contents</code>.</dd> +</dl> + +<h2 id="示例">示例</h2> + +<h3 id="有效标识符">有效标识符</h3> + +<pre>nono79 字母数字混合 +ground-level 字母-字母 +-test 连字符后跟字母 +_internal 下划线后跟字母 +\22 toto Unicode编码后跟字母 +bili\.bob 转义的句号 +</pre> + +<h3 id="无效标识符">无效标识符</h3> + +<pre class="example-bad">34rem 第一个字符不能是数字 +-12rad 第一个字符连字符后不能跟数字 +bili.bob 只有字母数字、连字符-、下划线_不需要转义 +--toto 第一个字符不能为连字符后跟连字符 +'bilibob' 不能用单引号包起来,这是一个字符串类型 +"bilibob" 不能用双引号包起来,这是一个字符串类型</pre> + +<h2 id="参考文档">参考文档</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('CSS Will Change', '#valdef-will-change-custom-ident', '<code><custom-ident></code> for <code>will-change</code>')}}</td> + <td>{{Spec2('CSS Will Change')}}</td> + <td>Defines which values are excluded for {{cssxref("will-change")}}.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Counter Styles', '#typedef-counter-style-name', '<code><custom-ident></code> for <code>list-style-type</code>')}}</td> + <td>{{Spec2('CSS3 Counter Styles')}}</td> + <td>Uses <code><custom-ident></code> instead of a finite list of keywords. Defines which values are excluded for {{cssxref("list-style-type")}} and {{cssxref("@counter-style")}}.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Lists', '#counter-properties', '<code><custom-ident></code> for <code>counter-*</code>')}}</td> + <td>{{Spec2('CSS3 Lists')}}</td> + <td>Renames <code><identifier></code> to <code><custom-ident></code>. Adds its usage to the new <code>counter-set</code> property.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Animations', '#typedef-single-animation-name', '<code><custom-ident></code> for <code>animation-name</code>')}}</td> + <td>{{Spec2('CSS3 Animations')}}</td> + <td>Defines which values are excluded for {{cssxref("animation-name")}}.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Values', '#identifier-value', '<code><custom-ident></code>')}}</td> + <td>{{Spec2('CSS3 Values')}}</td> + <td>Renames <code><identifier></code> to <code><custom-ident></code>. Makes it a pseudo-type and forbids the use of excluded values.</td> + </tr> + <tr> + <td>{{SpecName('CSS2.1', 'syndata.html#value-def-identifier', '<code><identifier></code>')}}</td> + <td>{{Spec2('CSS2.1')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>由于这种类型不是真正的类型,而是用于简化允许值描述的便利类型,因此没有浏览器兼容性信息。</p> |