任意路径排布文字
SVG:textPath
- 思路:使用
<path>创建一个路径(下面示例是一个圆),用<textPath>包裹文字,让文字沿着圆走
<div>
<svg viewBox="0 0 100 100">
<path d="M 0,50 a 50,50 0 1,1 0,1 z" id="circle" />
<text>
<textPath xlink:href="#circle">
hello, i am circle text, nice to meet you
</textPath>
</text>
</svg>
</div>
- 把 path 的 fill 设置为 none,去掉圆
- 由于文字被容器“剪切”掉了,所以用 margin 扩大容器,并让 svg 外也是可见的
将 path 更换为一个更酷炫的路径