Reputation: 623
example: http://jsfiddle.net/8H3Ay/2/.
Hello, I have an SVG icon with border added via css. I want to make it into one element (not svg icon and border separately), so that when I hover inside the circle or a little bit outside the circle, it'll change the border as well as the SVG icon color.
Also, if there's any other way I can make icons that will look well on small screens, please let me know. I looked into css sprites, but don't know how to make the icons scale well (mine get blurred, like normal .png images)
html:
<a href="#">
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="facebook" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="48px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<text transform="matrix(1 0 0 1 168.7834 543.8093)"><tspan x="0" y="0" fill="#FFFF00" font-family="'Verdana-Bold'" font-size="20">simpleicon.com</tspan><tspan x="-159.59" y="24" fill="#FFFF00" font-family="'Verdana'" font-size="20">Collection Of Flat Icon, Symbols And Glyph Icons</tspan></text>
<g id="_x23_020201ff">
<path fill="#444444" d="M223.22,71.227c16.066-15.298,38.918-20.465,60.475-21.109c22.799-0.205,45.589-0.081,68.388-0.072
c0.09,24.051,0.098,48.111-0.009,72.161c-14.734-0.026-29.478,0.036-44.212-0.026c-9.343-0.582-18.937,6.5-20.635,15.762
c-0.224,16.093-0.081,32.195-0.072,48.289c21.61,0.089,43.22-0.027,64.829,0.054c-1.582,23.281-4.47,46.456-7.858,69.541
c-19.088,0.179-38.187-0.018-57.274,0.099c-0.17,68.665,0.089,137.33-0.134,205.995c-28.352,0.116-56.721-0.054-85.072,0.08
c-0.537-68.674,0.044-137.383-0.295-206.066c-13.832-0.144-27.672,0.099-41.503-0.116c0.053-23.085,0.018-46.169,0.026-69.246
c13.822-0.169,27.654,0.036,41.477-0.098c0.42-22.442-0.421-44.91,0.438-67.333C203.175,101.384,209.943,83.493,223.22,71.227z"/>
</g>
</svg>
</a>
css:
#facebook{
border: 4px solid #444444;
border-radius: 50%;
padding: 10px;
}
#facebook:hover{
border:4px solid #3b5998;
}
#facebook path:hover{
fill:#3b5998;
}
Upvotes: 1
Views: 5237
Reputation: 99484
If I understood correctly, you want to change the color of whole SVG element on hover
.
If so, you need to change your CSS selectors as follows:
#facebook:hover {
border: 3px solid #3b5998;
}
#facebook:hover path { /* <-- change the 'path' fill color on hover */
fill: #3b5998;
}
Upvotes: 2