use*_*342 7 html javascript css svg
是否可以内联定义 textPath 的路径,而不是创建 def 并将其作为 xlink:href 作为属性进行引用?
<defs>
<path id="MyPath"
d="M 100 200
C 200 100 300 0 400 100" />
</defs>
<use xlink:href="#MyPath"/>
<text>
<textPath xlink:href="#MyPath">
My text along a path
</textPath>
</text>
Run Code Online (Sandbox Code Playgroud)
那么是否有可能有类似的东西
<text>
<textPath path="M 100 200 C 200 100 300 0 400 100">
My text along a path
</textPath>
</text>
Run Code Online (Sandbox Code Playgroud)
这不起作用,但像这样的事情?
这是新的 SVG 2 规范中的一项功能,您可以使用路径属性。
浏览器正在实施新的 SVG 2 功能。下面的示例确实可以在 Firefox 中运行,但不确定在其他地方。
html, body {
height: 100%;
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<svg height="100%" width="100%">
<text>
<textPath path="M 100 200 C 200 100 300 0 400 100">
My text along a path
</textPath>
</text>
</svg>Run Code Online (Sandbox Code Playgroud)