Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 文本锚定=";“开始”;不将文本元素移动到svg元素的开头。_Html_Css_Svg - Fatal编程技术网

Html 文本锚定=";“开始”;不将文本元素移动到svg元素的开头。

Html 文本锚定=";“开始”;不将文本元素移动到svg元素的开头。,html,css,svg,Html,Css,Svg,我有以下非常简单的SVG代码 <div> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 194 186" class="circliful"> <g stroke="#ccc"> <line x1="133" y1="50" x2="140" y2="40" stroke-width="2"></line> </g>

我有以下非常简单的SVG代码

<div>
  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 194 186" class="circliful">
  <g stroke="#ccc">
    <line x1="133" y1="50" x2="140" y2="40" stroke-width="2"></line>
  </g>
  <g stroke="#ccc">
    <line x1="140" y1="40" x2="200" y2="40" stroke-width="2"></line>
  </g>
  <circle cx="100" cy="100" r="57" class="border" fill="#eee" stroke="none" stroke-width="15" stroke-dasharray="360" transform="rotate(-90,100,100)"></circle>
  <circle class="circle" cx="100" cy="100" r="57" fill="none" stroke="#3498DB" stroke-width="5" stroke-dasharray="180, 20000" transform="rotate(-90,100,100)"></circle>
  <text text-anchor="middle" x="100" y="110" class="icon" style="font-size: 40px" fill="#3498DB"></text>
  <text class="timer" text-anchor="middle" x="175" y="35" style="font-size: 22px; undefined;" fill="#aaa">50%</text>
</svg>

</div>


50%
,我的困难在于以下svg元素以及文本锚属性如何与之配合使用:

<text class="timer" text-anchor="middle" x="175" y="35" style="font-size: 22px; undefined;" fill="#aaa">50%</text>
50%

现在,如果我更改
text-anchor=“start”
,text元素实际上不会移动到svg元素的开头,而是移动到它下面的行的开头,为什么?有谁能解释为什么<代码>文本锚=“开始”<代码>,没有按预期工作?

< p> <代码>文本锚< /C> >用来决定文本的X位置是否应该在文本的开头、结尾或中间。要移动文本位置,请更改其X和Y坐标

要将文本置于svg的开头,请执行以下操作:

x="0"
text-anchor="start"
x="194" //Width of the svg
text-anchor="end"
x="97" //Half of the width of the svg
text-anchor="middle"
要将文本放在svg的末尾,请执行以下操作:

x="0"
text-anchor="start"
x="194" //Width of the svg
text-anchor="end"
x="97" //Half of the width of the svg
text-anchor="middle"

将文本放在SVG的中间:

x="0"
text-anchor="start"
x="194" //Width of the svg
text-anchor="end"
x="97" //Half of the width of the svg
text-anchor="middle"

明亮的明亮的明亮的