I have an SVG element which is an arrow into a circle : https://jsfiddle.net/seabon/806ew03a/
<svg version="1.1" id="layer" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="15 15 102 102" style="enable-background:new 0 0 132 132;" xml:space="preserve" data-link="go_down">
<g class="cross-circle">
<g class="go-clockwise">
<circle class="st0" cx="66" cy="66" r="43.7"/>
</g>
</g>
<g class="down">
<polyline class="st1" points="76.4,71 66,81.4 55.6,71 "/>
<line class="st1" x1="66" y1="81" x2="66" y2="47"/>
</g>
</svg>
I would like to translate the arrow position with css. I tried to use position relative on the g element with the class "down" but it doesn't work. I tried to put a foreignObject but doesn't work too.. Does anybody have an idea ?
You can add transform:translate()
rules to your CSS stylesheet. This ought to work:
svg .down {
transform:translate(0,-4px);
transition:transform 0.3s;
}
svg:hover .down {
transform:translate(0,4px);
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
viewBox="15 15 102 102" width="200" height="200">
<g>
<g>
<circle class="st0" cx="66" cy="66" r="43.7" fill="#f00"/>
</g>
</g>
<g class="down">
<polyline points="76.4,71 66,81.4 55.6,71" fill="#fff"/>
<line x1="66" y1="81" x2="66" y2="47" stroke="#fff"/>
</g>
</svg>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With