为什么我的SVG精灵的一部分只显示背景?
我的原始图片是浅灰色,带有'>其中的符号。但是,当我将其转换为网站上的SVG Sprite时, https://svgsprit.es/ 。它变成了一个完整的黑色圆圈。我已经在stackoverflow中搜索了此内容,但还没有类似的答案。
原始SVG:
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 51 51">
<defs>
<style>.cls-1{fill:#393939;}.cls-2{fill:#fff;}</style>
</defs>
<circle class="cls-1" cx="25.5" cy="25.5" r="25.5"/>
<rect class="cls-2" x="24.4" y="27.9" width="1.6" height="15.24" rx="0.8" transform="matrix(0.78, -0.63, 0.63, 0.78, -21.26, 15.39)"/>
<rect class="cls-2" x="33.3" y="27.9" width="1.6" height="15.24" rx="0.8" transform="translate(24 -21.9) rotate(37.3)"/>
</svg>
精灵部分:
<symbol id="chevron" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 51 51">
<defs></defs>
<circle cx="25.5" cy="25.5" r="25.5"></circle>
<rect x="24.4" y="27.9" width="1.6" height="15.24" rx="0.8" transform="matrix(0.78, -0.63, 0.63, 0.78, -21.26, 15.39)"></rect>
<rect x="33.3" y="27.9" width="1.6" height="15.24" rx="0.8" transform="translate(24 -21.9) rotate(37.3)"></rect>
</symbol>
My original picture is a light grey with a '>' symbol in it. But when I convert it to svg sprite on website https://svgsprit.es/. It turns to a full black circle.I have search this in stackoverflow and no similar answer yet.
original svg:
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 51 51">
<defs>
<style>.cls-1{fill:#393939;}.cls-2{fill:#fff;}</style>
</defs>
<circle class="cls-1" cx="25.5" cy="25.5" r="25.5"/>
<rect class="cls-2" x="24.4" y="27.9" width="1.6" height="15.24" rx="0.8" transform="matrix(0.78, -0.63, 0.63, 0.78, -21.26, 15.39)"/>
<rect class="cls-2" x="33.3" y="27.9" width="1.6" height="15.24" rx="0.8" transform="translate(24 -21.9) rotate(37.3)"/>
</svg>
The sprite part:
<symbol id="chevron" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 51 51">
<defs></defs>
<circle cx="25.5" cy="25.5" r="25.5"></circle>
<rect x="24.4" y="27.9" width="1.6" height="15.24" rx="0.8" transform="matrix(0.78, -0.63, 0.63, 0.78, -21.26, 15.39)"></rect>
<rect x="33.3" y="27.9" width="1.6" height="15.24" rx="0.8" transform="translate(24 -21.9) rotate(37.3)"></rect>
</symbol>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
显然, svgsprit.es 无法处理您定义的CSS样式。如果您使用SVG的样式属性,则可以更好地工作:
结果:
Apparently svgsprit.es cannot handle the CSS styles you defined. If you use the style attributes for your SVG it works better:
Results in: