Svg Image Inline In Css
Here is a basic SVG image hover animation. Is there a way of coding this where I can avoid writing the SVG code twice?
Solution 1:
An idea would be to consider applying filter
to avoid duplicating the SVG code. You simply need to adjust the different values to obtain the colors you want.
body {
background-color: #181818;
}
a {
transition: all .3s ease;
width: 30px;
height: 30px;
display: inline-block;
}
#twitter {
background-image: url("data:image/svg+xml,%3Csvg style='fill: %2300aced' enable-background='new 0 0 612 612' version='1.1' viewBox='0 0 612 612' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m612 116.26c-22.525 9.981-46.694 16.75-72.088 19.772 25.929-15.527 45.777-40.155 55.184-69.411-24.322 14.379-51.169 24.82-79.775 30.48-22.907-24.437-55.49-39.658-91.63-39.658-69.334 0-125.55 56.217-125.55 125.51 0 9.828 1.109 19.427 3.251 28.606-104.33-5.24-196.84-55.223-258.75-131.17-10.823 18.51-16.98 40.078-16.98 63.101 0 43.559 22.181 81.993 55.835 104.48-20.575-0.688-39.926-6.348-56.867-15.756v1.568c0 60.806 43.291 111.55 100.69 123.1-10.517 2.83-21.607 4.398-33.08 4.398-8.107 0-15.947-0.803-23.634-2.333 15.985 49.907 62.336 86.199 117.25 87.194-42.947 33.654-97.099 53.655-155.92 53.655-10.134 0-20.116-0.612-29.944-1.721 55.567 35.681 121.54 56.485 192.44 56.485 230.95 0 357.19-191.29 357.19-357.19l-0.421-16.253c24.666-17.593 46.005-39.697 62.794-64.861z'%3E%3C/path%3E%3C/svg%3E");
filter:grayscale(100%) brightness(0.6);
}
#twitter:hover {
filter:grayscale(0%);
}
<aid="twitter"href="#"></a>
Related to get a different idea using mask
: https://stackoverflow.com/a/54802632/8620333
Post a Comment for "Svg Image Inline In Css"