我分析了一个大型的SVG文件,发现了这个奇怪的故障(点击此处查看演示)
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events">
<text>
<tspan x="0" y="1em" z-index="300">Word1</tspan>
<tspan x="0" dy="1em">Word2</tspan>
</text>
</svg>
用一行CSS代码即可实现:
svg { text-transform: uppercase; }
给出了错误的文字换行:
WORD1 W
ORD2
我自己解决了这个问题,但是我会把它留在这里,以防其他人在使用tspan文字换行和CSS时遇到问题并需要知道原因,或者可以解释为什么会发生这种情况,答案可能会有用。