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/_doublecolon_selection/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/_doublecolon_selection/index.html')
-rw-r--r-- | files/zh-cn/web/css/_doublecolon_selection/index.html | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/_doublecolon_selection/index.html b/files/zh-cn/web/css/_doublecolon_selection/index.html new file mode 100644 index 0000000000..ca1232e10d --- /dev/null +++ b/files/zh-cn/web/css/_doublecolon_selection/index.html @@ -0,0 +1,105 @@ +--- +title: '::selection' +slug: 'Web/CSS/::selection' +tags: + - CSS + - Layout +translation_of: 'Web/CSS/::selection' +--- +<p>{{ CSSRef() }}</p> + +<p><strong><code>::selection</code></strong> CSS伪元素应用于文档中被用户高亮的部分(比如使用鼠标或其他选择设备选中的部分)。</p> + +<pre class="brush: css">::selection { + background-color: cyan; +} +</pre> + +<h2 id="允许属性">允许属性</h2> + +<p>只有一小部分CSS属性可以用于<code>::selection</code> 选择器:</p> + +<ul> + <li>{{CSSxRef("color")}}</li> + <li>{{CSSxRef("background-color")}}</li> + <li>{{CSSxRef("cursor")}}</li> + <li>{{CSSxRef("caret-color")}}</li> + <li>{{CSSxRef("outline")}} and its longhands</li> + <li>{{CSSxRef("text-decoration")}} and its associated properties</li> + <li>{{CSSxRef("text-emphasis-color")}}</li> + <li>{{CSSxRef("text-shadow")}}</li> +</ul> + +<div class="blockIndicator warning"> +<p>要特别注意的是,{{ cssxref("background-image") }} 会如同其他属性一样被忽略。</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">/* Legacy Firefox syntax (version 61 and below) */ +::-moz-selection + +{{CSSSyntax}} +</pre> + +<h2 id="示例">示例</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html">This text has special styles when you highlight it. +<p>Also try selecting text in this paragraph.</p></pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css">::-moz-selection { + color: gold; + background-color: red; +} + +p::-moz-selection { + color: white; + background-color: blue; +}</pre> + +<pre class="brush: css">/* 选中的文本是红色背景,金黄色的字体 */ +::selection { + color: gold; + background-color: red; +} + +/*选中的是蓝色背景,白色的字体的段落*/ +p::selection { + color: white; + background-color: blue; +}</pre> + +<h3 id="结果">结果</h3> + +<p>{{EmbedLiveSample('示例')}}</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 Pseudo-Elements', '#selectordef-selection', '::selection')}}</td> + <td>{{ Spec2('CSS4 Pseudo-Elements')}}</td> + <td>Initial specification</td> + </tr> + </tbody> +</table> + +<div class="blockIndicator note"> +<p><code>::selection</code> CSS伪元素选择器是CSS第3级选择器的草案,但是在被推荐使用前就被废弃。它现在在第4级伪元素选择器草案中。</p> +</div> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{Compat("css.selectors.selection")}}</p> |