aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_doublecolon_placeholder/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/css/_doublecolon_placeholder/index.html')
-rw-r--r--files/zh-cn/web/css/_doublecolon_placeholder/index.html169
1 files changed, 169 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_doublecolon_placeholder/index.html b/files/zh-cn/web/css/_doublecolon_placeholder/index.html
new file mode 100644
index 0000000000..959bd15c4c
--- /dev/null
+++ b/files/zh-cn/web/css/_doublecolon_placeholder/index.html
@@ -0,0 +1,169 @@
+---
+title: '::placeholder'
+slug: 'Web/CSS/::placeholder'
+translation_of: 'Web/CSS/::placeholder'
+---
+<div>{{CSSRef}}{{SeeCompatTable}}</div>
+
+<p><a href="/en-US/docs/Web/CSS/Pseudo-elements">伪元素</a><strong><code>::placeholder</code></strong>可以选择一个表单元素的<a href="/en-US/docs/Web/HTML/Forms_in_HTML#The_placeholder_attribute">占位文本</a>,它允许开发者和设计师自定义<a href="/en-US/docs/Web/HTML/Forms_in_HTML#The_placeholder_attribute">占位文本</a>的样式。</p>
+
+<pre class="brush: css no-line-numbers">::placeholder {
+ color: red;
+ font-size: 1.5em;
+}</pre>
+
+<p>在使用了<code>::placeholder</code>伪元素的选择器中,仅有小一部分CSS属性可以使用,这个集合可以参考{{cssxref("::first-line")}}伪元素。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: css">{{csssyntax}}
+</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="红色文本">红色文本</h3>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html">&lt;input placeholder="我是红色的!"&gt;</pre>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css">input::placeholder {
+ color: red;
+ font-size: 1.2em;
+ font-style: italic;
+}</pre>
+
+<h4 id="结果">结果</h4>
+
+<p>{{ EmbedLiveSample('红色文本') }}</p>
+
+<h3 id="绿色文本">绿色文本</h3>
+
+<p> </p>
+
+<h4 id="HTML_2">HTML</h4>
+
+<pre class="brush: html">&lt;input placeholder="而我是绿色的!"&gt;</pre>
+
+<h4 id="CSS_2">CSS</h4>
+
+<pre class="brush: css">input::placeholder {
+ color: green;
+}</pre>
+
+<h4 id="结果_2">结果</h4>
+
+<p>{{EmbedLiveSample('绿色文本')}}</p>
+
+<p> </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('CSS4 Pseudo-Elements', '#placeholder-pseudo', '::placeholder')}}</td>
+ <td>{{Spec2('CSS4 Pseudo-Elements')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>功能</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Edge</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>基本支持</td>
+ <td>{{CompatChrome(57)}}</td>
+ <td>{{CompatGeckoDesktop("51.0")}}<sup>[1]</sup></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>44</td>
+ <td>10.1</td>
+ </tr>
+ <tr>
+ <td>前缀支持</td>
+ <td>Supported</td>
+ <td>Supported</td>
+ <td>Supported</td>
+ <td>10 -ms-</td>
+ <td>Supported</td>
+ <td>5 -webkit-</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>功能</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>基本支持</td>
+ <td>{{CompatChrome(57)}}</td>
+ <td>{{CompatChrome(57)}}</td>
+ <td>{{CompatGeckoMobile("52.0")}}</td>
+ <td>{{CompatNo}}</td>
+ <td> </td>
+ <td>10.3</td>
+ </tr>
+ <tr>
+ <td>前缀支持</td>
+ <td>Supported</td>
+ <td>Supported</td>
+ <td>Supported</td>
+ <td>10 -ms-</td>
+ <td>Supported</td>
+ <td>5 -webkit-</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] 在Gecko 51.0 {{geckoRelease("51.0")}} 以及更低的版本中,请使用 {{cssxref("::-moz-placeholder")}} 。</p>
+
+<h2 id="相似阅读">相似阅读</h2>
+
+<ul>
+ <li>{{cssxref(":placeholder-shown")}}</li>
+ <li>与此伪元素选择器功能相同的几个浏览器私有选择器:
+ <ul>
+ <li>{{cssxref("::-webkit-input-placeholder")}}</li>
+ <li>{{cssxref("::-moz-placeholder")}}</li>
+ <li>{{cssxref(":-ms-input-placeholder")}}</li>
+ </ul>
+ </li>
+ <li><a href="/en-US/docs/Web/HTML/Forms_in_HTML">Forms in HTML</a></li>
+ <li>{{HTMLElement("input")}}</li>
+ <li>{{HTMLElement("textarea")}}</li>
+</ul>