SVG gradient fill doesn't work

2019-07-01 20:03发布

I'm trying to add a gradient background to an SVG path. The path is black, instead. This is the code I've got:

<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>

What am I missing?

Thanks

标签: svg
1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-01 20:26

linearGradient has a capital G in it. Your snippet above has it as lineargradient

查看更多
登录 后发表回答