I am trying to achieve an animated effect on an SVG line icon only when it is hovered over. I want the icon to remain static when not being hovered. While I have managed to animate the drawing effect and make it work somewhat on hover, I am facing an issue where the dashes of the line get smaller during the transition between the 'from' and 'to' keyframes, leading to a less smooth drawing effect than I had hoped for. I am working on this using only HTML and CSS.
.bell_line:hover {
animation: draw 3s linear forwards;
}
@keyframes draw {
from {
stroke-dashoffset:92;
stroke-dasharray: 92;
}
to {
stroke-dashoffset:0;
stroke-dasharray: 0;
}
}
<div class="bell_line" style="margin-left: 100px;margin-top: 100px;">
<svg class="bell_line" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60.85 38.83">
<g data-name="bell_line" fill="none" stroke="#000" stroke-linecap="round" stroke-miterlimit="10">
<path class="bell_line" d="M18.43 28.41l5.38-14.11v-3a5.62 5.62 0 0111.23 0v3l5.33 14.11zM29.38 5.67V.5M29.38 33.2v5.13"/>
</g>
</svg>
</div>