2014-07-25 82 views
0

我想以文本向左而不是向右擴展的方式將文本對齊到圓形元素。意思是說,右邊界總是處於相同的位置。將文本對齊到圓形

<svg version="1.1" class="merge" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" 
    viewBox="0 0 180 35" enable-background="new 0 0 180 35" xml:space="preserve" width="180px" height="35px"> 
    <circle cx="103.4" cy="28.1" r="4.8"/> 
    <text y="10">works</text> 
    <circle cx="103.4" cy="5.6" r="4.8"/> 
    <text y="33">does not work at all</text> 
</svg> 

http://jsfiddle.net/3XeXv/

與現在這一權利的問題是,當文本變長,它覆蓋了一圈。

如果可能我想這樣做,而不必移動JavaScript的文本。

+0

它必須使用SVG?那麼HTML/CSS怎麼樣? – andi

回答

0

使用文本錨屬性與價值底:

<text text-anchor="end" y="30" x="100">Where X defines the position of the text end</text>