将textPath方向从逆时针方向翻转到顺时针方向?

时间:2015-04-12 11:28:18

标签: html css html5 css3 svg

默认情况下,SVG以逆时针方式围绕路径包装文本。文本的天花板坚持了道路。如何将方向改为顺时针方向,使文字的地板贴在圆周而不是天花板上?

.textspace
{
	letter-spacing: 5px;
	font-family: fantasy;
	font-size: 50px;
	writing-mode: tb;
}

.curved-text
{
	font-family: fantasy;
	font-size: 20px;
	letter-spacing: 5px;
	word-spacing: 10px;
}
	<svg height="400" width="400">
		<defs>
			<path	d="M60,60
						A50,50
						0 
						1,0
						61,60"
						stroke="black"
						stroke-width="2"
						fill="none"
						id="tracker-path"/>
		</defs>
		<text x="50" y="50" class="curved-text">
			<textPath xlink:href="#tracker-path">
				Tracking succesful.
			</textPath>
		</text>
	</svg>

1 个答案:

答案 0 :(得分:3)

我设法解决了这个问题。您需要做的就是将sweep-flag的值从0设置为1。这将翻转path

的方向

&#13;
&#13;
.textspace
{
	letter-spacing: 5px;
	font-family: fantasy;
	font-size: 50px;
	writing-mode: tb;
}

.curved-text
{
	font-family: fantasy;
	font-size: 20px;
	letter-spacing: 5px;
	word-spacing: 10px;
}
&#13;
<svg height="400" width="400">
		<defs>
			<path	 d="M80,160
						A50,50
						0 
						1,1
						81,160"
						stroke="black"
						stroke-width="2"
						fill="none"
						id="tracker-path"/>
		</defs>
		<text x="50" y="50" class="curved-text">
			<textPath xlink:href="#tracker-path">
				Tracking succesful.
			</textPath>
		</text>
	</svg>
&#13;
&#13;
&#13;