How to draw a number centered inside a circle with inline svg?

后端 未结 1 1958
温柔的废话
温柔的废话 2021-01-06 03:29

I\'m trying to write a Django template tag that will generate a number inside a circle as an inline svg.

The math is pretty straight-forward (except for the fudge-fa

1条回答
  •  北海茫月
    2021-01-06 04:07

    You can't really rely on the alignment-baseline property. Support for it is pretty spotty at best.

    Even when it is supported, alignment-baseline: middle doesn't really vertically centre the characters. There is, in fact, no way to do it accurately and reliably.

    You can centre horizontally with text-anchor="middle", which is supported everywhere.

    IMO, the best you can do in the vertical case, is the solution I propose in this answer: https://stackoverflow.com/a/19273331/1292848

    0 讨论(0)
提交回复
热议问题