M
M
Minusator2017-01-28 08:33:31
css
Minusator, 2017-01-28 08:33:31

Svg image on top of another svg image on hover?

Hello. I am adding an svg image to the site. The task is to make, when hovering over, a change to another svg image. On the Internet I found how to change the fill color. This is not it.

<a href="{vk_url}" target="_blank" class="soc_vk"><svg class="icon icon-vk"><use xlink:href="#icon-vk"></use></svg></a>

I tried using css, but the image appears below the image
.soc_vk:hover {
    background-image: url(/templates/Default/images/hover_svg/vk_hover.svg);
  
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2017-01-28
@Minusator

If you do it via <use>, then 2 are required.

<svg class="icon icon-vk">
  <use class='svg1' xlink:href="#icon-vk"></use>
  <use class='svg2' xlink:href="#icon-hover"></use>
</svg>

and styles
.soc_vk:hover .svg1{ display: none; }
.soc_vk:hover .svg2{ display: inline; }

.soc_vk:not(:hover) .svg1{ display: inline; }
.soc_vk:not(:hover) .svg2{ display: none; }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question