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/descendant_combinator | |
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/descendant_combinator')
-rw-r--r-- | files/zh-cn/web/css/descendant_combinator/index.html | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/descendant_combinator/index.html b/files/zh-cn/web/css/descendant_combinator/index.html new file mode 100644 index 0000000000..69aec535c7 --- /dev/null +++ b/files/zh-cn/web/css/descendant_combinator/index.html @@ -0,0 +1,109 @@ +--- +title: 后代选择器 +slug: Web/CSS/Descendant_combinator +tags: + - CSS + - Selectors +translation_of: Web/CSS/Descendant_combinator +--- +<div>{{CSSRef("Selectors")}}</div> + +<p><strong>后代组合器</strong>(通常用单个空格(<code> </code>)字符表示)组合了两个选择器,如果第二个选择器匹配的元素具有与第一个选择器匹配的祖先(父母,父母的父母,父母的父母的父母等)元素,则它们将被选择。利用后代组合器的选择器称为<dfn>后代选择器</dfn>。</p> + +<pre class="brush: css no-line-numbers notranslate">/* List items that are descendants of the "my-things" list */ +ul.my-things li { + margin: 2em; +}</pre> + +<p>从技术上讲,后代组合器是两个选择器之间的一个或多个 {{Glossary("CSS")}} 空格字符-空格字符和/或四个控制字符之一:回车,换页,换行和制表符在没有其他组合器的情况下。此外,组成组合器的空白字符可以包含任意数量的CSS注释。</p> + + + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox notranslate"><var>selector1</var> <var>selector2</var> { + <var>/* property declarations */</var> +}</pre> + +<h2 id="Examples">Examples</h2> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css notranslate">li { + list-style-type: disc; +} + +li li { + list-style-type: circle; +} +</pre> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html notranslate"><ul> + <li> + <div>Item 1</div> + <ul> + <li>Subitem A</li> + <li>Subitem B</li> + </ul> + </li> + <li> + <div>Item 2</div> + <ul> + <li>Subitem A</li> + <li>Subitem B</li> + </ul> + </li> +</ul> +</pre> + +<h3 id="Result">Result</h3> + +<p>{{EmbedLiveSample("Examples", "100%", 160)}}</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", "#descendant-combinators", "descendant combinator")}}</td> + <td>{{Spec2("CSS4 Selectors")}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName("CSS3 Selectors", "#descendant-combinators", "descendant combinator")}}</td> + <td>{{Spec2("CSS3 Selectors")}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName("CSS2.1", "selector.html#descendant-selectors", "descendant selectors")}}</td> + <td>{{Spec2("CSS2.1")}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName("CSS1", "#contextual-selectors", "contextual selectors")}}</td> + <td>{{Spec2("CSS1")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("css.selectors.descendant")}}</p> + +<h2 id="相关">相关</h2> + +<ul> + <li><a href="/en-US/docs/Web/CSS/Child_combinator">Child combinator</a></li> +</ul> |