我有一些SVG图标,我放在网页的svg圈子中间。 我对所有图像使用与Snap相同的javascript函数,但只有一个没有正确居中...
我试图将svg直接放入html进行测试(参见http://jsfiddle.net/aop5znab/)但是你可以注意到,球被正确放置,但不是那个人,也应该在左上角(比如,在球下......)。
据我所知SVG,可以使用transform
attribut或直接在路径中更改位置(相对路径或绝对路径点)。我的图标没有transform
属性,因此我认为它只能是以不同方式定位的路径点。
任何人都可以告诉我,我是否正确?
transform
请这是我的SVG:
<g style="fill:#808080">
<g fill="#0ea507">
<circle cx="75.042" cy="68.168999" r="4.3889999" fill="#0ea507" d="M 79.431,68.168999 C 79.431,70.592976 77.465978,72.557999 75.042,72.557999 72.618022,72.557999 70.653,70.592976 70.653,68.168999 70.653,65.745021 72.618022,63.779999 75.042,63.779999 77.465978,63.779999 79.431,65.745021 79.431,68.168999 z"/>
<g fill="#0ea507">
<g fill="#0ea507">
<g fill="#0ea507">
<polyline
points="67.165,87.193 70.991,77.023 74.929,77.023"
fill="#0ea507" />
<path
d="M 67.165,89.22 C 66.928,89.22 66.687,89.178 66.451,89.089 65.404,88.695 64.875,87.527 65.269,86.48 L 69.096,76.31 C 69.393,75.521 70.148,74.998 70.992,74.998 H 74.93 C 76.049,74.998 76.956,75.905 76.956,77.024 76.956,78.143 76.049,79.049 74.93,79.049 H 72.393 L 69.06,87.907 C 68.755,88.719 67.984,89.22 67.165,89.22 z"
id="path3010"
fill="#0ea507" />
</g>
<g
fill="#0ea507">
<polyline
points="82.92,87.193 79.094,77.023 75.155,77.023"
fill="#0ea507" />
<path
d="M 82.92,89.22 C 82.101,89.22 81.329,88.719 81.024,87.907 L 77.691,79.049 H 75.154 C 74.035,79.049 73.129,78.142 73.129,77.024 73.129,75.905 74.036,74.998 75.154,74.998 H 79.093 C 79.936,74.998 80.692,75.521 80.989,76.31 L 84.815,86.48 C 85.209,87.527 84.68,88.695 83.633,89.089 83.399,89.177 83.158,89.22 82.92,89.22 z"
fill="#0ea507" />
</g>
</g>
<path
d="M 75.042,75.006 C 75.042,75.006 80.782,74.556 80.219,80.183 79.656,85.81 77.63,103.365 76.617,103.478 75.604,103.591 75.942,103.703 75.042,103.703 74.142,103.703 74.479,103.591 73.467,103.478 72.454,103.365 70.428,85.809 69.865,80.183 69.302,74.557 75.042,75.006 75.042,75.006 z"
fill="#0ea507" />
</g>
</g>
</g>
注意:我尝试了this,但它没有改变任何内容......
答案 0 :(得分:0)
我找到的最佳解决方案是使用inkscape,就像在这个帖子中回答:Removing transforms in SVG files
以下是答案中建议步骤的副本/过去:
删除Inkscape中的转换
Edit > XML Editor
transform
属性并将其删除如何在不创建其他转换属性的情况下完全移动所有对象
Object > Ungroup
Edit > Select All in All Layers
Object > Transform
然后在“变换”面板中
Relative move
并查看Apply to each object separately
Horizontal
和Vertical
值,然后点击Apply