admin管理员组文章数量:1292269
I am drawing a simple two rectangle svg as follows:
<svg width="72px" height="72px" viewBox="0 0 72 72" xmlns="">
<rect stroke-dashoffset="0" x="2.4px" y="2.4px"></rect>
<rect ng-class="$ctrl.expiryClass"
x="2.4px" y="2.4px"
stroke-dasharray={{$ctrl.dashlength}}
stroke-dashoffset={{$ctrl.offset}}></rect>
</svg>
This works well in chrome and looks like this:
However, the svg is not showing up in FireFox and I am only seeing the purple 2h
box.
Any idea whats going on?
I am drawing a simple two rectangle svg as follows:
<svg width="72px" height="72px" viewBox="0 0 72 72" xmlns="http://www.w3/2000/svg">
<rect stroke-dashoffset="0" x="2.4px" y="2.4px"></rect>
<rect ng-class="$ctrl.expiryClass"
x="2.4px" y="2.4px"
stroke-dasharray={{$ctrl.dashlength}}
stroke-dashoffset={{$ctrl.offset}}></rect>
</svg>
This works well in chrome and looks like this:
However, the svg is not showing up in FireFox and I am only seeing the purple 2h
box.
Any idea whats going on?
- There some questions about the stroke-dashoffset not workin in firefox, like this one stackoverflow./questions/18298482/… – Vega Commented Aug 18, 2017 at 22:22
- 4 The rect has no width and height attributes. – Robert Longson Commented Aug 18, 2017 at 22:36
2 Answers
Reset to default 11I expect you are setting the rectangle's width
and height
using CSS. Correct?
If so, that's an SVG 2 thing that currently only works in Chrome. You'll need to use regular width
and height
attributes if you want this to be cross-browser patible.
<rect stroke-dashoffset="0" x="2.4px" y="2.4px" width="100px" height="100px"/>
As @paul mentioned its a problem with rect()
You can easily convert an SVG rect to a path with inkscape.
Open the .svg in inskape, click on layers, select all rects, convert them to path (cmd shift C). Then go to Object/Transform... and click on apply. Save the file.
本文标签: javascriptSVG rect not showing up in firefox but works on chromeStack Overflow
版权声明:本文标题:javascript - SVG rect not showing up in firefox but works on chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741550350a2384844.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论