aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/svg/element/use/index.html
blob: 7502e54a6e022634bed8da1c3cef3aca35aaab58 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
title: use
slug: Web/SVG/Element/use
tags:
  - Elemento
  - Gráficos(2)
  - Referencia
  - Referência(2)
  - SVG
  - graficos
translation_of: Web/SVG/Element/use
---
<div>{{SVGRef}}</div>

<p>O elemento <code>use</code> cria instâncias dentro de um documento SVG e os duplica em outro local. O efeito é o mesmo se as instâncias forem profundamente clonadas em um DOM não exposto, e então coladas onde o elemento <code>use</code> está (muito parecido com <a href="/pt-BR/docs/Web/HTML/Element/template">elementos de template</a> clonados no HTML5). Como as instâncias clonadas não são expostas, é preciso ter cuidado ao utilizar <a href="/pt-BR/CSS" title="en/CSS">CSS</a> para estilizar o elemento <code>use</code> e seus descendentes ocultos. Não há garantia de que atributos CSS sejam herdados pelo DOM oculto e clonado, a menos que você os solicite explicitamente usando <a href="/pt-BR/CSS/inheritance" title="en/CSS/inheritance">herança CSS</a>.</p>

<p>Por motivos de segurança alguns navegadores poderão aplicar uma política de "mesma origem" com elementos <code>use</code>, bem como poderão recusar o carregamento de uma URI de múltiplas origens no atributo <code>xlink:href</code>.</p>

<h2 id="Contexto_de_uso">Contexto de uso</h2>

<p>{{svginfo}}</p>

<h2 id="Exemplo">Exemplo</h2>

<pre class="brush: xml" id="Attributes">&lt;svg width="100%" height="100%" xmlns="<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>" xmlns:xlink="<a href="http://www.w3.org/1999/xlink">http://www.w3.org/1999/xlink</a>"&gt;
  &lt;style&gt;
    .classA { fill:red }
  &lt;/style&gt;
  &lt;defs&gt;
    &lt;g id="Port"&gt;
      &lt;circle style="fill:inherit" r="10"/&gt;
    &lt;/g&gt;
  &lt;/defs&gt;

  &lt;text y="15"&gt;black&lt;/text&gt;
  &lt;use x="50" y="10" xlink:href="#Port" /&gt;
  &lt;text y="35"&gt;red&lt;/text&gt;
  &lt;use x="50" y="30" xlink:href="#Port" class="classA"/&gt;
  &lt;text y="55"&gt;blue&lt;/text&gt;
  &lt;use x="50" y="50" xlink:href="#Port" style="fill:blue"/&gt;
 &lt;/svg&gt;
</pre>

<p> </p>

<h2 id="Atributos">Atributos</h2>

<h3 id="Atributos_globais">Atributos globais</h3>

<ul>
 <li><a href="/pt-BR/SVG/Attribute#ConditionalProccessing" title="en/SVG/Attribute#ConditionalProccessing">Atributos de processamento condicional</a> »</li>
 <li><a href="/pt-BR/SVG/Attribute#Core" title="en/SVG/Attribute#Core">Atributos principais</a> »</li>
 <li><a href="/pt-BR/SVG/Attribute#GraphicalEvent" title="en/SVG/Attribute#GraphicalEvent">Atributos de eventos gráficos</a> »</li>
 <li><a href="/pt-BR/SVG/Attribute#Presentation" title="en/SVG/Attribute#Presentation">Atributos de apresentação</a> »</li>
 <li><a href="/pt-BR/SVG/Attribute#XLink" title="en/SVG/Attribute#XLink">Atributos XLink</a> »</li>
 <li>{{ SVGAttr("class") }}</li>
 <li>{{ SVGAttr("style") }}</li>
 <li>{{ SVGAttr("externalResourcesRequired") }}</li>
 <li>{{ SVGAttr("transform") }}</li>
</ul>

<h3 id="Atributos_específicos">Atributos específicos</h3>

<ul>
 <li>{{ SVGAttr("x") }}</li>
 <li>{{ SVGAttr("y") }}</li>
 <li>{{ SVGAttr("width") }}</li>
 <li>{{ SVGAttr("height") }}</li>
 <li>{{ SVGAttr("xlink:href") }}</li>
</ul>

<h2 id="Interface_DOM">Interface DOM</h2>

<p>Este elemento implementa a interface do <code><a href="/pt-BR/DOM/SVGUseElement" title="en/DOM/SVGUseElement">SVGUseElement</a></code>.</p>

<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidade dos navegadores</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
  <tr>
   <td>Load from external URI</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{CompatNo()}}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
  <tr>
   <td>Load from data: URI</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatGeckoDesktop("10.0") }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
  <tr>
   <td>Load from external URI</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
  <tr>
   <td>Load from data: URI</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>