textPath
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2015å¹´7æâ©.
* Some parts of this feature may have varying levels of support.
é¤äºç¬ç´å°ç»å¶ä¸è¡æå以å¤ï¼SVG ä¹å¯ä»¥æ ¹æ® <path> å
ç´ çå½¢ç¶æ¥æ¾ç½®æåãåªè¦å¨textPathå
ç´ å
鍿¾ç½®ææ¬ï¼å¹¶éè¿å
¶xlink:href屿§å¼å¼ç¨<path>å
ç´ ï¼æä»¬å°±å¯ä»¥è®©æåååç°å¨<path>å
ç´ ç»å®çè·¯å¾ä¸äºã
使ç¨ä¸ä¸æ
示ä¾
html
<svg
width="100%"
height="100%"
viewBox="0 0 1000 300"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path
id="MyPath"
d="M 100 200
C 200 100 300 0 400 100
C 500 200 600 300 700 200
C 800 100 900 100 900 100" />
</defs>
<use xlink:href="#MyPath" fill="none" stroke="red" />
<text font-family="Verdana" font-size="42.5">
<textPath xlink:href="#MyPath">
We go up, then we go down, then up again
</textPath>
</text>
<!-- Show outline of the viewport using 'rect' element -->
<rect
x="1"
y="1"
width="998"
height="298"
fill="none"
stroke="black"
stroke-width="2" />
</svg>
峿¶ç»æï¼
屿§
>å ¨å±å±æ§
䏿屿§
DOM æ¥å£
该å
ç´ å®ç°äº SVGTextPathElement æ¥å£ã