aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/attribute/text-anchor/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/svg/attribute/text-anchor/index.html')
-rw-r--r--files/zh-cn/web/svg/attribute/text-anchor/index.html96
1 files changed, 96 insertions, 0 deletions
diff --git a/files/zh-cn/web/svg/attribute/text-anchor/index.html b/files/zh-cn/web/svg/attribute/text-anchor/index.html
new file mode 100644
index 0000000000..31d75a3209
--- /dev/null
+++ b/files/zh-cn/web/svg/attribute/text-anchor/index.html
@@ -0,0 +1,96 @@
+---
+title: text-anchor
+slug: Web/SVG/Attribute/text-anchor
+tags:
+ - 可缩放矢量图形
+ - 可缩放矢量图形 属性
+translation_of: Web/SVG/Attribute/text-anchor
+original_slug: Web/SVG/Attribute/文本锚点
+---
+<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG Attribute reference home</a></p>
+
+<p>文本锚点属性被用来描述该文本与所给点的对齐方式 (开头、中间、末尾对齐) 。</p>
+
+<p>文本锚点属性被运用到每个 {{ SVGElement("text") }} 元素的独立文本块上。 每个文本块有一个初始的当前文本位置,一个来源于 {{ SVGElement("text") }} 元素的{{ SVGAttr("x") }}和{{ SVGAttr("y") }}属性在当前上下文的用户坐标系中所对应的点,任何 一个{{ SVGElement("tspan") }}、{{SVGElement("tref") }}、{{ SVGElement("altGlyph") }} 元素的 {{ SVGAttr("x") }} 或者 {{ SVGAttr("y") }} 属性值都明确指向了文本块里第一个被呈现的字符,或者是决定了{{ SVGElement("textPath") }}元素的当前文本位置的初始值。</p>
+
+<p>作为一个描述性的属性,它也可以直接用作css样式的性质(style属性的值)。</p>
+
+<h2 id="使用方法">使用方法</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="row">类别</th>
+ <td>呈现属性</td>
+ </tr>
+ <tr>
+ <th scope="row">值</th>
+ <td>start | middle | end | <strong title="this is the default value">inherit</strong></td>
+ </tr>
+ <tr>
+ <th scope="row">可动画化</th>
+ <td>是</td>
+ </tr>
+ <tr>
+ <th scope="row">标准文件</th>
+ <td><a class="external" href="http://www.w3.org/TR/SVG/text.html#TextAnchorProperty" title="http://www.w3.org/TR/SVG/text.html#TextAnchorProperty">SVG 1.1 (2nd Edition)</a></td>
+ </tr>
+ </tbody>
+</table>
+
+<dl>
+ <dt>start</dt>
+ <dd>所呈现的字符对齐方式为:文本字符串的开始位置即当前文本的初始位置.对于拉丁文在其通常文本排列方向,这就相当于左对齐. 对于脚本像希伯来语和阿拉伯语这类自右向左排列的文字来说,这相当于右对齐. 对于亚洲某些垂直走向的文本来说,这相当于向上对齐。</dd>
+ <dt>middle</dt>
+ <dd>所呈现的字符对齐方式为:文本字符串的中间位置即当前文本的初始位置. (对于按路径排列的文本,会从概念上首先将其文本排列在一条直线上,确定该串中点位置后,然再将该文本映射到路径上,并且将之前确定的中点放置在当前文本的位置上 )</dd>
+ <dt>end</dt>
+ <dd>所呈现的字符对齐方式为:文本字符串的末尾即当前文本的初始位置.对于拉丁语通常的文字走向来说,这就相当于右对齐. 对于像希伯来语和阿拉伯语这类将文字自右向左排列的脚本来说,这相当于左对齐.</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: html">&lt;?xml version="1.0"?&gt;
+&lt;svg width="120" height="120" viewBox="0 0 120 120"
+ xmlns="http://www.w3.org/2000/svg" version="1.1"&gt;
+
+ &lt;!-- Materialisation of anchors --&gt;
+ &lt;path d="M60,15 L60,110 M30,40 L90,40 M30,75 L90,75 M30,110 L90,110" stroke="grey" /&gt;
+
+
+ &lt;!-- Anchors in action --&gt;
+ &lt;text text-anchor="start"
+ x="60" y="40"&gt;A&lt;/text&gt;
+
+ &lt;text text-anchor="middle"
+ x="60" y="75"&gt;A&lt;/text&gt;
+
+ &lt;text text-anchor="end"
+ x="60" y="110"&gt;A&lt;/text&gt;
+
+ &lt;!-- Materialisation of anchors --&gt;
+ &lt;circle cx="60" cy="40" r="3" fill="red" /&gt;
+ &lt;circle cx="60" cy="75" r="3" fill="red" /&gt;
+ &lt;circle cx="60" cy="110" r="3" fill="red" /&gt;
+
+&lt;style&gt;&lt;![CDATA[
+text{
+ font: bold 36px Verdana, Helvetica, Arial, sans-serif;
+}
+]]&gt;&lt;/style&gt;
+&lt;/svg&gt;</pre>
+
+<p><strong>Live sample</strong></p>
+
+<p>{{ EmbedLiveSample('Example','120','120') }}</p>
+
+<h2 id="元素">元素</h2>
+
+<p> </p>
+
+<p>以下元素可以运用文本锚点属性:</p>
+
+<p> </p>
+
+<ul>
+ <li><a href="/en/SVG/Element#Text_content_elements" title="en/SVG/Element#TextContent">Text content elements</a> »</li>
+</ul>