svg,路径标签在 Firefox 上不起作用

2022-01-18 00:00:00 path firefox tags svg html

我正在制作一张带有 svg 路径标签的简单地图但它不适用于火狐或 IE(图纸本身不出现)

I am working on a simple map drowning with svg path tag But it dose not work on fire fox or IE (the drawing itself does not appear)

听到是其中的一个样本

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<path id="lineAB" d= "M450.59,294.28l3.64-0.29l5.97,8.44l-5.54,4.18l-4.01-1.03l-5.39,0.07l-0.87,3.16l-4.52,0.22l-1.24-1.69l1.6-5.14L450.59,294.28L450.59,294.28z" stroke="blue" stroke-width="3" fill="blue" onclick="alert('Hello')"/>
</svg>

推荐答案

d 属性不应该使用逗号,而是使用空格.stroke-width 也必须是一个长度(例如 px).这应该有效:

You shouldn't be using commas for the d attribute, use spaces instead. Also stroke-width has to be a length (e.g. px). This should work:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<path id="lineAB" d= "M450.59 294.28l3.64-0.29l5.97 8.44l-5.54 4.18l-4.01-1.03l-5.39 0.07l-0.87 3.16l-4.52 0.22l-1.24-1.69l1.6-5.14L450.59 294.28L450.59 294.28z" stroke="blue" stroke-width="3px" fill="blue" onclick="alert('Hello')"/>
</svg>

请参阅 规范 以获得更长更准确的解释 :).

See the spec for a longer and more accurate explanation :).

相关文章