【发布时间】:2018-12-27 22:46:40
【问题描述】:
上下文:
试图将 SVG 路径文本放在圆形图像的顶部。
方形图片使用rounded-circle 进行四舍五入。围绕它绘制 SVG 路径并用于编写文本。结果:
代码:https://jsfiddle.net/ghLn4jkt/
<div class="mt-3 row">
<div class="col-9 CircleThing" style="background-color: coral;">
<img src="https://via.placeholder.com/500/" alt="contact" class="rounded-circle">
<svg width="600" height="600">
<!--Base circle for the text-->
<!--<circle id="curve" cx="270" cy="270" r="260" stroke="black" stroke-width="3" fill="red" />-->
<path id="curve" fill="transparent"
d="M 10, 270
a 260,260 0 1,0 520,0
a 260,260 0 1,0 -520,0 " />
<text width="520">
<textPath xlink:href="#curve" >
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</textPath>
</text>
</svg>
</div>
</div>
CSS:
.CircleThing {
font-family: Gill Sans Extrabold;
font-size: 50px;
}
问题:
在我最后一次尝试中,我遇到了多个问题:
1/。 svg 不在 img 之上。
2/。文本从左下角开始,而我希望它在右边。
为了创建路径,我首先做了一个 SVG 圆圈,在阅读 https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d 后推断它的路径是:
M cx, cy
a r,r 0 1,0 (r * 2),0
a r,r 0 1,0 -(r * 2),0
3/.文字颠倒或由内向外。对于右上角的四分之一
【问题讨论】:
-
尝试将svg设置为绝对左侧:0
标签: html css twitter-bootstrap svg