嵌套svg忽略Chrome和Opera中的转换

nested svg ignores transformation in Chrome and Opera

本文关键字:转换 Opera svg 忽略 Chrome 嵌套      更新时间:2023-09-26

我经历了一些我称之为bug的事情。我有以下2个svg:

<svg height="100%" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" id="SvgjsSvg1004">
  <defs id="SvgjsDefs1005"></defs>
  <g transform="matrix(2,0,0,2,50,50)" id="SvgjsG1011">
    <rect height="50" width="50" id="SvgjsRect1012"></rect>
  </g>
</svg>
<svg height="100%" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" id="SvgjsSvg1004">
  <defs id="SvgjsDefs1005"></defs>
  <svg transform="matrix(2,0,0,2,50,50)" style="overflow: visible;" id="SvgjsSvg1011">
    <rect height="50" width="50" id="SvgjsRect1012"></rect>
  </svg>
</svg>

在firefox中,这两个片段看起来是一样的(和预期的一样)。两者之间的唯一区别是第二个使用嵌套svg而不是组。

当您在chrome或opera中查看此示例时,您将看到,嵌套svg上的转换完全被忽略。

有人能解释这种行为吗?

根据http://www.w3.org/TR/SVG/struct.html#SVGElement, SVGSVGElement不允许转换