【发布时间】:2021-12-31 14:09:34
【问题描述】:
我有一个 svg 绿色标记,其中包含一个居中的文本并带有一些属性。有趣的是,与具有相同属性的相同文本相比,它看起来更大胆。
您可以看到绿色标记中的文本看起来比其他文本更粗。为什么会发生这种情况以及如何使绿色气球中的文本与其他文本一样不那么粗?
<svg width="41" height="51" xmlns = "http://www.w3.org/2000/svg" >
<path d="M40 20.3907C40 22.3845 39.3035 24.7755 38.1354 27.3685C36.971 29.9536 35.3565 32.6995 33.5626 35.3918C29.975 40.776
25.697 45.9056 22.9467 49.0441C21.6333 50.5429 19.3667 50.5429 18.0533 49.0441C15.303 45.9056 11.025 40.776 7.4374 35.3918C5.64351
32.6995 4.02903 29.9536 2.86459 27.3685C1.69655 24.7755 1 22.3845 1 20.3907C1 9.6841 9.72786 1 20.5 1C31.2721 1 40 9.6841 40 20.3907Z"
fill = "#73BD07" stroke = "white" />
<text x="50%" y="20" font-size="12px" dominant-baseline="middle" stroke="#000000" text-anchor="middle">7234</text>
</svg>
<text x="50%" y="20" font-size="12px" dominant-baseline="middle" stroke="#000000" text-anchor="middle">7234</text>
【问题讨论】:
-
svg 元素外的文本不是有效标签。没有文本标签,你会看到同样的结果