How can I cause this svg to fill when I hover? I looked at a fair amount of documentation and tried several ways but was unsuccessfully.
Here is my html:
<a class="anchor-class" href="#"><svg class="svg-class"></svg></a>
And i have tried the following in my css
a svg:hover {
fill: #50c8e8;
}
as well as
.anchor-class svg:hover{
fill: #50c8e8;
}
and even
.svg-class :hover{
fill:#50c8e8;
}
What am I doing wrong? I should be able to accomplish this with css, right?
EDIT: It might help to note that this image is being used as a background image. a little more detail in the css below:
.svg-class {
background-repeat: no-repeat;
background-size: 20px 20px;
height: 20px;
width: 20px;
display: inline-block;
.background-image('path.svg')
}
EDIT 2: Here is the .svg code, not sure that it is important though
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
<style type="text/css">
.st0{fill:#E4E4E4;}
</style>
<path id="XMLID_154_" class="st0" d="M85.5,15c-19.5-19.4-51-19.4-70.4,0c-19.5,19.4-19.5,51,0,70.4c19.5,19.5,51,19.4,70.4,0
C105,66,105,34.4,85.5,15z M49.5,9c5.3,0,9.5,4.3,9.5,9.5c0,5.3-4.3,9.6-9.5,9.6c-5.3,0-9.6-4.3-9.6-9.6C39.9,13.2,44.1,9,49.5,9z
M64.8,79.1c0,2-1,3-3,3H37.3c-2,0-3-1-3-3v-6.3c0-2,1-3,3-3h4.5V43.4h-4.6c-2,0-3-1-3-3v-6.3c0-2,1-3,3-3h17.2c2,0,3,1,3,3v35.7
h4.6c2,0,3,1,3,3V79.1z"/>
</svg>
UPDATE: with the svg code that you posted, you can do this behavior in this way.
Example:
a .svg-class:hover path {
fill: #50c8e8;
}
.svg-class {
height: 20px;
width: 20px;
display: inline-block;
}
<a class="anchor-class" href="#">
<svg class="svg-class" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
<style type="text/css">
.st0{fill:#E4E4E4;}
</style>
<path id="XMLID_154_" class="st0" d="M85.5,15c-19.5-19.4-51-19.4-70.4,0c-19.5,19.4-19.5,51,0,70.4c19.5,19.5,51,19.4,70.4,0
C105,66,105,34.4,85.5,15z M49.5,9c5.3,0,9.5,4.3,9.5,9.5c0,5.3-4.3,9.6-9.5,9.6c-5.3,0-9.6-4.3-9.6-9.6C39.9,13.2,44.1,9,49.5,9z
M64.8,79.1c0,2-1,3-3,3H37.3c-2,0-3-1-3-3v-6.3c0-2,1-3,3-3h4.5V43.4h-4.6c-2,0-3-1-3-3v-6.3c0-2,1-3,3-3h17.2c2,0,3,1,3,3v35.7
h4.6c2,0,3,1,3,3V79.1z"/>
</svg>
</a>
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