【发布时间】:2012-06-21 18:17:11
【问题描述】:
我的.svg 文件中有以下图片:
<image xlink:href="developer.mozilla.png" x="50%" y="50%" height="62" width="71"/>
我希望它显示在页面的中间,但似乎左上角在中间。如何让图片的中心显示在页面的中心?
【问题讨论】:
我的.svg 文件中有以下图片:
<image xlink:href="developer.mozilla.png" x="50%" y="50%" height="62" width="71"/>
我希望它显示在页面的中间,但似乎左上角在中间。如何让图片的中心显示在页面的中心?
【问题讨论】:
这样的事情应该可以工作:
<image xlink:href="developer.mozilla.png" x="50%" y="50%" height="62" width="71" transform="translate(-35.5,-31)"/>
【讨论】:
height 或width 不是像素,这将不起作用
这是一种方法...
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg x="50%" y="50%" width="258px" height="221px" overflow="visible">
<image x="-129px" y="-110.5px" width="258px" height="221px" xlink:href="http://images2.wikia.nocookie.net/__cb20110303182948/hogwartsrpg/images/9/95/KittenCareCat.png"/>
</svg>
</svg>
【讨论】: