firefox - chrome和firefox之间的SVG模式不一致

标签 firefox google-chrome svg

我有一个渐变覆盖指定为图案的纯色(红色):

<svg width="480" height="480">
    <defs>

        <pattern width="1" height="1" x="0" y="0" id="pattern">
            <rect width="240" height="240" x="0" y="0" fill="rgba(255,0,0,1)"/>
            <rect width="240" height="240" x="0" y="0" fill="url(#gradient)"/>
        </pattern>

        <linearGradient id="gradient" x1="0" y1="1" x2="0" y2="0">
            <stop offset="0%" stop-color="rgb(0,0,0)" stop-opacity="1"/>
            <stop offset="100%" stop-color="rgb(0,0,0)" stop-opacity="0"/>
        </linearGradient>

    </defs>
    <path
      transform="matrix(1,0,0,1,200,200)"
      d="M0 0M 120 0 A 120 120 0 0 0 -120 0 A 120 120 0 0 0 120 0"
      fill="url(#pattern)"
    />
</svg>

左:火狐。右: Chrome

enter image description here

右边的(Chrome)是正确的。

有谁知道如何在 Firefox 中完成这项工作?

现场观看:http://jsbin.com/eyenoh/edit#html,live

最佳答案

通过使用对象边界框作为图案内容的坐标系,我能够让它工作。

<pattern width="1" height="1" x="0" y="0" id="pattern" patternContentUnits="objectBoundingBox">
    <rect width="1" height="1" x="0" y="0" fill="rgba(255,0,0,1)"/>
    <rect width="1" height="1" x="0" y="0" fill="url(#gradient)"/>
</pattern>

在这里看到它:
http://jsbin.com/efesev/edit#html,live

我会尝试进一步调查。看起来很适合提交错误报告。

关于firefox - chrome和firefox之间的SVG模式不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8929731/

相关文章:

javascript - 在 Chrome 或 Firefox 上使用 Visual Studio 2015 调试 Javascript

javascript - Localstorage 在 Firefox 中无法正常工作。返回空对象

javascript - 如何判断 DOM 元素在当前视口(viewport)中是否可见?

css - css添加的引号在Chrome和IE10中显示不同

html - 如何将 SVG 插入按钮?

SVG 可访问性导致无效的 HTML(重复 ID)

javascript - jQuery .html ('<img>' ) 在 FF 和 Opera 中不起作用

javascript - Chrome 使用 Pixi.js 加载 Sprite

Javascript:如何查看 toString 等 native 函数的源代码实现

html - 如何根据事件选项卡隐藏/显示动画 svg?