我有textContent"Design"和text-anchor作为开头的文本,用css转换为45度旋转.所以它旋转了.问题是我需要调整旋转后文本的(x,y)位置,以显示勾选之间的文本,如预期图中所示.我怎样才能做到这一点.
结果:http: //imageshack.us/content_round.php?page = done&l = img404/2711/result1h.png
预期:http://imageshack.us/content_round.php?page = done&l = img266 / 5138 / expected1.png
<svg>
<text x="100" y="100" width="64" height="16" fill="black" transform="rotate(45,100,100)" text-anchor="start">Design</text>
</svg>
Run Code Online (Sandbox Code Playgroud)
谢谢Gowri
文本需要水平和垂直居中,因此旋转不会移动它:
<text x="100" y="50" text-anchor="middle"
dominant-baseline="central" transform="rotate(0, 100, 50)"></text>
Run Code Online (Sandbox Code Playgroud)
text-anchor水平
dominant-baseline对齐文本垂直对齐文本
svg {
width: 200px; height: 100px;
text-align: center;
border: solid 1px blue;
font-family: monospace;
}Run Code Online (Sandbox Code Playgroud)
<svg>
<text x="100" y="50" text-anchor="middle" dominant-baseline="central" transform="rotate(180, 100, 50)">
Hello World
</text>
<text x="100" y="50" text-anchor="middle" dominant-baseline="central" transform="rotate(0, 100, 50)">
Hello World
</text>
</svg>Run Code Online (Sandbox Code Playgroud)
示例:http://jsfiddle.net/e4bAh/131/