aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_placeholder-shown
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/_colon_placeholder-shown
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/_colon_placeholder-shown')
-rw-r--r--files/zh-cn/web/css/_colon_placeholder-shown/index.html92
1 files changed, 92 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_colon_placeholder-shown/index.html b/files/zh-cn/web/css/_colon_placeholder-shown/index.html
new file mode 100644
index 0000000000..86fd5a91c9
--- /dev/null
+++ b/files/zh-cn/web/css/_colon_placeholder-shown/index.html
@@ -0,0 +1,92 @@
+---
+title: ':placeholder-shown'
+slug: 'Web/CSS/:placeholder-shown'
+translation_of: 'Web/CSS/:placeholder-shown'
+---
+<div>{{CSSRef}}{{SeeCompatTable}}</div>
+
+<p><strong><code>:placeholder-shown</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/zh-CN/docs/CSS/Pseudo-classes">伪类</a> 在 {{htmlElement("input")}} 或 {{htmlElement("textarea")}} 元素显示 <a href="/en-US/docs/Web/HTML/Element/input#attr-placeholder">placeholder text</a> 时生效.</p>
+
+<pre class="brush: css no-line-numbers">/* 选择所有显示占位符(placeholder)的元素 */
+:placeholder-shown {
+ border: 2px solid silver;
+}</pre>
+
+<h2 id="参数">参数</h2>
+
+<pre class="syntaxbox">:placeholder-shown</pre>
+
+<h2 id="样例">样例</h2>
+
+<h3 id="基础样例">基础样例</h3>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html">&lt;input placeholder="Type something here!"&gt;</pre>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css; highlight[6]">input {
+ border: 2px solid black;
+ padding: 3px;
+}
+
+input:placeholder-shown {
+ border-color: silver;
+}</pre>
+
+<h4 id="结果">结果</h4>
+
+<p>{{EmbedLiveSample('Basic_example', 200, 60)}}</p>
+
+<h3 id="超出文本">超出文本</h3>
+
+<p>在分辨率较小的设备上, 输入框或者其他表单控件可能会变的很窄. 这个选择器可以使得占位符文本缩短. 这个选择器经常和 {{cssxref("text-overflow")}} 一起使用.</p>
+
+<h4 id="HTML_2">HTML</h4>
+
+<pre class="brush: html">&lt;input placeholder="Enter something into this field, if you please!"&gt;</pre>
+
+<h4 id="CSS_2">CSS</h4>
+
+<pre class="brush: css">input:placeholder-shown {
+ text-overflow: ellipsis;
+}</pre>
+
+<h4 id="结果_2">结果</h4>
+
+<p>{{EmbedLiveSample("Overflowing_text", 200, 60)}}</p>
+
+<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("CSS4 Selectors", "#placeholder", ":placeholder-shown")}}</td>
+ <td>{{Spec2("CSS4 Selectors")}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("css.selectors.placeholder-shown")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>The {{cssxref("::placeholder")}} pseudo-element styles the placeholder <em>itself</em>.</li>
+ <li>Related HTML elements: {{HTMLElement("input")}}, {{HTMLElement("textarea")}}</li>
+ <li>{{cssxref(":-moz-placeholder")}}, {{cssxref("::-moz-placeholder")}}</li>
+ <li><a href="/en-US/docs/Learn/HTML/Forms">HTML forms</a></li>
+</ul>