I've been trying to animate my SVG icon, but I seem to be missing something. I'm still fairly new to CSS animations.
The issue I'm facing is that the position of the SVG isn't correct when the website loads. Additionally, during the animation (on hover), it seems like the dimensions of the SVG "div" are changing and getting rescaled.
Is there a way to keep the SVG in its original "cross" shape while allowing it to rotate on its own axis without losing its main dimensions?
#logo{
animation-name: spin;
animation-duration: 4000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
transform-origin: center;
animation-play-state: paused;
}
svg:hover #logo{
animation-play-state: running;
}
@keyframes spin{
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="logo">
<svg width="35px" height="35px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve">
<g>
<rect id="logo" x="16.57" y="-4.86" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -8.2843 20)" width="6.86" height="49.71"/>
</g>
<g>
<rect id="logo" x="-4.86" y="16.57" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -8.2843 20)" width="49.71" height="6.86"/>
</g>
</svg>
</div>