aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_last-child/index.html
blob: e4720413c3af7e349393fcf4a01ebc3d6307ac2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: ':last-child'
slug: 'Web/CSS/:last-child'
translation_of: 'Web/CSS/:last-child'
---
<div>{{CSSRef}}</div>

<h2 id="概述">概述</h2>

<p><code>:last-child</code> CSS <a href="/en-US/docs/Web/CSS/Pseudo-classes">伪类</a> 代表父元素的最后一个子元素。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">{{csssyntax}}</pre>

<h2 id="示例">示例</h2>

<h3 id="HTML_内容">HTML 内容</h3>

<pre class="brush: html">&lt;ul&gt;
  &lt;li&gt;此元素背景色不是lime&lt;/li&gt;
  &lt;li&gt;我的也不是lime。&lt;/li&gt;
  &lt;li&gt;我的才是lime! :)&lt;/li&gt;
&lt;/ul&gt;</pre>

<h3 id="CSS_内容">CSS 内容</h3>

<pre class="brush: css">li:last-child {
  background-color: lime;
}</pre>

<p>{{EmbedLiveSample('%E7%A4%BA%E4%BE%8B', '100%', 100)}}</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', '#last-child', ':last-child')}}</td>
   <td>{{Spec2('CSS4 Selectors')}}</td>
   <td>No change</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Selectors', '#last-child', ':last-child')}}</td>
   <td>{{Spec2('CSS3 Selectors')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器支持">浏览器支持</h2>


<div class="hidden">The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div>

<p>{{Compat("css.selectors.last-child")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{cssxref(":first-child")}}</li>
 <li>{{cssxref(":nth-child")}}</li>
 <li>{{cssxref(":last-of-type")}}</li>
</ul>