I have arrow created in svg and I display it in my html.
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="8" viewBox="0 0 28 18">
<g id="Group1" data-name="Group1" transform="translate(28.321 -0.144) rotate(90)">
<rect id="Rectangle_1107" data-name="Rectangle 1107" width="5" height="22" transform="translate(6.144 6.321)" fill="#000000"/>
<path id="Pol_1" data-name="Pol 1" d="M9,0l9,14H0Z" transform="translate(0.144 0.321)" fill="#000000"/>
</g>
</svg>
now I need the following behavior: if I move the mouse over the arrow, the arrow should lengthen and change color, something like below:
So on default arrow is short and black and then, after hover, arrow should be red and longer. How can I achieve it in css?
2
Answers
Use the hover selector.
You can also use transition to have a smooth effect.
You can use a CSS transition. The transform property of a SVG element can be styled using CSS. I am just moving the left part of the arrow outside the view box and back again on hover.
Here I also use the currentColor for both stroke and fill to show how the color could be defined in the context, like a parent HTML element.