SVG渐变填充不起作用。

3

我试图为SVG路径添加渐变背景,但路径仍然是黑色的。

这是我当前的代码:

<svg style="overflow: hidden; position: relative; " height="150" version="1.1" width="290" xmlns="http://www.w3.org/2000/svg">
...
    <defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); ">
        <lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
            <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1"></stop>
            <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"></stop>
        </lineargradient>
    </defs>
    <path style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); " fill="url(#grad1)" stroke="none" d="M100,114L74,114L74,83L100,83Z"></path>
...
</svg>

我错过了什么?

谢谢。

1个回答

2

linearGradient中的G是大写字母。您上面的片段将其写成了lineargradient


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接