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_enabled/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_enabled/index.html')
-rw-r--r-- | files/zh-cn/web/css/_colon_enabled/index.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_colon_enabled/index.html b/files/zh-cn/web/css/_colon_enabled/index.html new file mode 100644 index 0000000000..ac57afafaf --- /dev/null +++ b/files/zh-cn/web/css/_colon_enabled/index.html @@ -0,0 +1,101 @@ +--- +title: ':enabled' +slug: 'Web/CSS/:enabled' +tags: + - CSS + - Reference + - Web + - 伪类 + - 参考 + - 布局 +translation_of: 'Web/CSS/:enabled' +--- +<div>{{CSSRef}}</div> + +<p><a href="/zh-CN/docs/Web/CSS">CSS</a> <a href="/zh-CN/CSS/Pseudo-classes">伪类</a> <strong><code>:enabled</code></strong> 表示任何被启用的(enabled)元素。如果一个元素能够被激活(如选择、点击或接受文本输入),或者能够获取焦点,则该元素是启用的。元素也有一个禁用的状态(disabled state),在被禁用时,元素不能被激活或获取焦点。</p> + +<pre class="brush: css no-line-numbers">/* 选择任何启用状态的 <input> */ +input:enabled { + color: blue; +}</pre> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="示例">示例</h2> + +<p>下面的代码,当文本输入框处于启用状态时,输入框 {{htmlElement("input")}} 的文本是绿色的,处于禁用状态时,输入框的文本则是灰色的。这样可以把元素是否可用反馈给用户。</p> + +<p>HTML:</p> + +<pre class="brush:html"><form action="url_of_form"> + <label for="FirstField">First field (enabled):</label> + <input type="text" id="FirstField" value="Lorem"><br> + + <label for="SecondField">Second field (disabled):</label> + <input type="text" id="SecondField" value="Ipsum" disabled="disabled"><br> + + <input type="button" value="Submit"> +</form></pre> + +<p>CSS:</p> + +<pre class="brush:css;">input:enabled { + color: #2b2; +} + +input:disabled { + color: #aaa; +} +</pre> + +<h3 id="结果">结果</h3> + +<div>{{EmbedLiveSample("Enabled_Disabled_Inputs_Example",550,95)}}</div> + +<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-enabled', ':enabled')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>No change.</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', '#selector-enabled', ':enabled')}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>Defines the semantics for HTML and forms.</td> + </tr> + <tr> + <td>{{SpecName('CSS4 Selectors', '#enableddisabled', ':enabled')}}</td> + <td>{{Spec2('CSS4 Selectors')}}</td> + <td>No change.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Selectors', '#enableddisabled', ':enabled')}}</td> + <td>{{Spec2('CSS3 Selectors')}}</td> + <td>Defines the pseudo-class, but not the associated semantics.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("css.selectors.enabled")}}</p> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{ Cssxref(":disabled") }}</li> +</ul> |