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/_colon_default/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/_colon_default/index.html')
-rw-r--r-- | files/zh-cn/web/css/_colon_default/index.html | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_colon_default/index.html b/files/zh-cn/web/css/_colon_default/index.html new file mode 100644 index 0000000000..e7a3c59512 --- /dev/null +++ b/files/zh-cn/web/css/_colon_default/index.html @@ -0,0 +1,135 @@ +--- +title: ':default' +slug: 'Web/CSS/:default' +translation_of: 'Web/CSS/:default' +--- +<div>{{CSSRef}}</div> + +<p> <strong><code>:default</code></strong> <a href="https://developer.mozilla.org/en-US/docs/Web/CSS">CSS</a> <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes">pseudo-class</a> 表示一组相关元素中的默认表单元素。</p> + +<p>该选择器可以在 {{htmlelement("button")}}, <code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox"><input type="checkbox"></a></code>, <code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio"><input type="radio"></a></code>, 以及 {{htmlelement("option")}} 上使用。</p> + +<pre class="brush: css no-line-numbers language-css"><code class="language-css"><span class="comment token">/* Selects any default <input> */</span> +<span class="selector token">input<span class="pseudo-class token">:default</span> </span><span class="punctuation token">{</span> + <span class="property token">background-color</span><span class="punctuation token">:</span> lime<span class="punctuation token">;</span> +<span class="punctuation token">}</span></code></pre> + +<p>允许多个选择的分组元素也可以具有多个默认值,即,它们可以具有最初选择的多个项目。在这种情况下,所有默认值都使用 <code>:default</code> 伪类表示。例如,您可以在一组复选框之间设置默认复选框。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="示例">示例</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><input type="radio" name="season" id="spring"> +<label for="spring">Spring</label> + +<input type="radio" name="season" id="summer" checked> +<label for="summer">Summer</label> + +<input type="radio" name="season" id="fall"> +<label for="fall">Fall</label> + +<input type="radio" name="season" id="winter"> +<label for="winter">Winter</label></pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css">input:default { + box-shadow: 0 0 2px 1px coral; +} + +input:default + label { + color: coral; +}</pre> + +<h3 id="结果">结果</h3> + +<p>{{EmbedLiveSample('示例')}}</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('HTML WHATWG', '#selector-default', ':default')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>无变化</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', '#selector-default', ':default')}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>定义了HTML语义和规范验证</td> + </tr> + <tr> + <td>{{SpecName('CSS4 Selectors', '#default-pseudo', ':default')}}</td> + <td>{{Spec2('CSS4 Selectors')}}</td> + <td>无变化</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Basic UI', '#pseudo-default', ':default')}}</td> + <td>{{Spec2('CSS3 Basic UI')}}</td> + <td>定义了伪类,但不关联伪类</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>10.0</td> + <td>{{CompatGeckoDesktop("2.0")}}</td> + <td>{{CompatNo}}</td> + <td>10.0</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("2.0")}}</td> + <td>{{CompatNo}}</td> + <td>10.0</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> |