SVG图像标记在Firefox或IE中无法使用

时间:2013-10-30 20:47:29

标签: svg

以下SVG <image>标记未在Firefox 25或IE10中显示任何内容。它在Chrome中有效。我在做什么错了,在这里?

的test.html

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <script type="text/javascript">
    </script>
  </head>
  <body>
    <svg width="4in" height="3in" version="1.1" viewBox="0 0 500 500"
        xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <image x="50" y="50" width="100px" height="100px" xlink:href="test.svg"></image>
    </svg>
  </body>
</html>

test.svg

<svg xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="463.85715"
   height="375.28571"
   id="svg2">
  <g
     id="layer1">
    <rect
       width="462.85715"
       height="374.28571"
       x="145.71429"
       y="80.933617"
       id="rect2985"
       style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-opacity:1" />
  </g>
</svg>

1 个答案:

答案 0 :(得分:1)

问题是svg文件中的根元素需要viewBox属性。这就是我从我正在研究的测试用例中删除Inkscape代码所得到的......