Skip to content Skip to sidebar Skip to footer

Is It Possible To Use An Image In Place Of The Stroke Of An Svg Path?

First off, I know this question is very similar to this question, but I tried implementing that solution with an SVG PATH and it did not work. I also know that another solution wou

Solution 1:

That's a Chrome/Safari bug you're relying on.

stroke:url(#pattern);

is actually shorthand for

stroke:url(<this file>#pattern);

but there's no pattern in the css file. Chrome gets this wrong, Firefox gets it right. If you fix the reference Firefox will work but unfortunately Chrome won't any longer. The most compatible solution would therefore be to move your CSS (at least the bit that references the pattern) into the SVG file itself within <style> tags.

Solution 2:

It works fine on firefox. I am not sure what the problem is that you are having.

#container svg {
  fill: none;
  stroke-width: 10px;
  stroke: url(#pattern);
  stroke-dasharray:1628;
  stroke-dashoffset:1628.1;
  animation:polyline 3.15s linear 0.5s forwards;
}

@keyframes polyline {
  to {
    stroke-dashoffset:0;
  }
}
<divid="container"><svg><defs><patternid="pattern"width="1600"height="800"patternUnits="userSpaceOnUse"><imagexlink:href="http://lorempixel.com/1600/800/nature"width="1600"height="800" /></pattern></defs><pathd="M0,5
             L184,5
             C202,5 202,5 202,36
             L202,86
             L327,85
             L421,166
             L460,166
             L499,132
             L588,211
             L617,211
             L712,134
             L748,165
             L780,165
             L830,111
             L913,212
             L938,212
             L1028,140
             L1078,184
             L1107,184
             L1152,140
             L1263,249
             L1263,248"
          /></svg></div>

Post a Comment for "Is It Possible To Use An Image In Place Of The Stroke Of An Svg Path?"