How to center SVG text vertically in IE9

后端 未结 3 522
说谎
说谎 2021-01-07 20:43

In order to align text vertically in SVG one has to use the dominant-baseline attribute. This has already been discussed on SO (Aligning text in SVG) and is par

3条回答
  •  伪装坚强ぢ
    2021-01-07 21:07

    One way to accomplish this in IE is to set the position related to the size of the font:

     M 
    

    Setting the "dy" attribute will shift the text up (if value is negative) or down (if value is positive). Setting the "text-anchor" attribute centers the text on the x axis just fine in IE. Although this might hackish, but so is IE's support of SVG!

提交回复
热议问题