Manitoba
Manitoba

Reputation: 8702

SVG background not applied

I've made a simple SVG image but the background isn't applied whereas it should.

I got the following code so far:

<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" id="content" width="100%" height="100%" viewbox="0 0 800 1000" preserveaspectratio="xMidYMid meet" version="1.1">
  <defs>
    <lineargradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stop-color="#ffffff" stop-opacity="0"/>
      <stop offset="100%" stop-color="orange" stop-opacity="0.8"/>
    </lineargradient>
    <lineargradient id="gradientLine" x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stop-color="orange" stop-opacity="0"/>
      <stop offset="100%" stop-color="orange" stop-opacity="0.6"/>
    </lineargradient>
  </defs>
  <g id="vis" transform="translate(330,670)">
    <path fill="url(#gradient)" d="M-112.87131548350527,-640.1250394579351A650,650 0 0,1 222.31309316168483,-610.8002035108404L0,0Z"/>
    <circle r="35" stroke="orange" fill="orange" opacity="1"/>
    <circle r="3" stroke="black" fill="black" opacity="1"/>
    <line x1="0" x2="-85" y1="0" y2="0" fill="black" stroke="black"/>
  </g>
</svg>

The path is black but it should be a gradient going from white to orange.

Apparently, when I run my code in jsfiddle, it displays the good result. But when I try to display the SVG in an img tag or directly in my browser, I got a black background. Any idea ?

Did I make something wrong or is this a common issue ?

Thanks for your help.

Upvotes: 0

Views: 44

Answers (1)

Andrew Surzhynskyi
Andrew Surzhynskyi

Reputation: 2776

I think the problem is here:

<lineargradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">

Fixed:

<linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">

Upvotes: 2

Related Questions