0

I have a simple SVG with a path element:

<svg id="corners" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><title>Corners</title>
    <rect width="120" height="120" fill="#262626"/>
    <path id="star" class="morph" d="M62.379999999999995 3.1399999999999864L79.58000000000001 38 118 43.56999999999999 90.21000000000001 70.69999999999999l6.57 38.3 -34.4 -18.08L28 109l6.57 -38.3 -27.83 -27.12L45.18000000000001 38z" fill="#8cc63f"/>
</svg>

How can I add a background image (with a little parallax scroll) in the background of the path element? style="background-image:url()" is not working.

sao
  • 1,835
  • 6
  • 21
  • 40
angelique000
  • 899
  • 3
  • 10
  • 28
  • Solution you're looking for may be in this topic: [similar topic](https://stackoverflow.com/questions/3796025/fill-svg-path-element-with-a-background-image) – Andrzej Gorgoń Oct 30 '19 at 20:56
  • yes I found that post. But how can I add a little parallax scrolling to it? – angelique000 Oct 30 '19 at 21:05
  • 1
    I think that you can try to do it using JavaScript. For example: onScroll event which inside you can put some code which would change the `y` value of the image. – Andrzej Gorgoń Oct 30 '19 at 22:08

0 Answers0