aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/_colon_any-link/index.html
blob: 58a8a126cfb3f11ba1a7bfb53449f8f3b75f0bd7 (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
72
73
---
title: ':any-link'
slug: 'Web/CSS/:any-link'
tags:
  - CSS
  - 实验性
translation_of: 'Web/CSS/:any-link'
---
<div>{{CSSRef}} {{SeeCompatTable}}</div>

<p><strong><code>:any-link</code></strong>  <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/Pseudo-classes">伪类</a> 选择器代表一个有链接锚点的元素,而不管它是否被访问过,也就是说,它会匹配每一个有 <code>href</code> 属性的 {{HTMLElement("a")}}{{HTMLElement("area")}} 或 {{HTMLElement("link")}} 元素。因此,它会匹配到所有的 {{cssxref(":link")}} 或 {{cssxref(":visited")}}</p>

<pre class="brush: css no-line-numbers  language-css"><code class="language-css"><span class="selector token"><span class="pseudo-class token">/* 选中任意匹配 :link 和 :visited 元素*/
</span></span></code><code>:any-link {
  color: green;
}</code>
</pre>

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

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

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

<div id="example">

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;a href="https://example.com"&gt;External link&lt;/a&gt;&lt;br&gt;
&lt;a href="#"&gt;Internal target link&lt;/a&gt;&lt;br&gt;
&lt;a&gt;Placeholder link (won't get styled)&lt;/a&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">a:any-link {
  border: 1px solid blue;
  color: orange;
}

/* WebKit browsers */
a:-webkit-any-link {
  border: 1px solid blue;
  color: orange;
}
</pre>
</div>

<p>{{EmbedLiveSample('Example')}}</p>

<h2 id="Specifications">Specifications</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", "#the-any-link-pseudo", ":any-link")}}</td>
   <td>{{Spec2('CSS4 Selectors')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

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

<p>{{Compat("css.selectors.any-link")}}</p>