Search code examples
javascriptjquerysvgjquery-animatevelocity

Rotate SVG image on its axis.


I have this svg .

<svg>
       <path xmlns="http://www.w3.org/2000/svg" fill="#012d26" d=" M 81.16 38.23 C 83.16 42.68 85.01 47.20 87.05 51.63 C 89.59 57.31 91.99 63.04 94.50 68.73 C 107.87 65.61 122.71 76.15 123.25 90.07 C 124.68 103.15 112.95 115.43 99.93 115.20 C 87.82 115.97 76.31 106.03 75.34 93.93 C 74.34 84.23 80.19 74.37 89.14 70.51 C 87.75 64.47 86.08 58.49 84.69 52.45 C 83.60 47.69 82.33 42.97 81.16 38.23 Z"/>
    </svg>

and i want to rotate it on its axis. Like a meter needle.

I tried ..

transform: rotateZ(0deg);

but, this is rotating the entire image. I want to keep the base fixed and only rotate the needle part.


Solution

  • This can be done by :

    transform-origin:bottom; 
    transform: rotateZ(0deg);