blob: 597c101d51d12ff479d9ed7310893edcd43de067 (
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
|
---
title: a
slug: Web/SVG/Element/a
tags:
- SVG
- SVG容器
- 元素
translation_of: Web/SVG/Element/a
---
<div>{{SVGRef}}</div>
<p>使用 SVG 的锚元素 (<a>) 定义一个超链接。</p>
<p>由于这个元素和 <a href="/en-US/docs/Web/HTML/Element/a">HTML 的 <a> 标签</a> 使用了相同的标签名,当使用 CSS 或 <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector">querySelector</a> 选择"a"时,可能应用到错误的元素上。 可以尝试使用 </code><a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/@namespace"><code>@namespace</code>规则</a> 来区分两者</p>
<h2 id="用法">用法</h2>
<p>{{svginfo}}</p>
<h2 id="示例">示例</h2>
<pre class="brush: html"><svg width="140" height="30"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="https://developer.mozilla.org/en-US/docs/SVG"
target="_blank">
<rect height="30" width="120" y="0" x="0" rx="15"/>
<text fill="white" text-anchor="middle"
y="21" x="60">SVG on MDN</text>
</a>
</svg></pre>
<p>示例结果:</p>
<p>{{EmbedLiveSample("示例",170,60)}}</p>
<h2 id="属性">属性</h2>
<h3 id="全局属性">全局属性</h3>
<ul>
<li><a href="/en-US/docs/SVG/Attribute#ConditionalProccessing" title="SVG/Attribute#ConditionalProccessing">条件处理属性</a> »</li>
<li><a href="/en-US/docs/SVG/Attribute#Core" title="SVG/Attribute#Core">核心属性</a> »</li>
<li><a href="/en-US/docs/SVG/Attribute#GraphicalEvent" title="SVG/Attribute#GraphicalEvent">图形事件属性</a> »</li>
<li><a href="/en-US/docs/SVG/Attribute#Presentation" title="SVG/Attribute#Presentation">外观属性</a> »</li>
<li><a href="/en-US/docs/SVG/Attribute#XLink" title="SVG/Attribute#XLink">Xlink属性</a> »</li>
<li>{{SVGAttr("class")}}</li>
<li>{{SVGAttr("style")}}</li>
<li>{{SVGAttr("externalResourcesRequired")}}</li>
<li>{{SVGAttr("transform")}}</li>
</ul>
<h3 id="专有属性">专有属性</h3>
<ul>
<li>{{SVGAttr("xlink:show")}}</li>
<li>{{SVGAttr("xlink:actuate")}}</li>
<li>{{SVGAttr("xlink:href")}}</li>
<li>{{SVGAttr("target")}}</li>
</ul>
<h2 id="DOM_接口">DOM 接口</h2>
<p>该元素实现了<code><a href="/en-US/docs/DOM/SVGAElement" title="DOM/SVGAElement">SVGAElement</a></code>接口。</p>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("svg.elements.a")}}
|