I am just working on a beginner project, and when I hover over the Instagram Icon, I would like it to slowly transition to the gradient of colors from some svg code I copied off of StackOverflow. I understand how the SVG code works (generally), but cannot figure out how to make the transitions work.
Here's a snippet of necessary code, along with the css that I've tried so far.
I believe the end transition value for fill
is what is causing the issue. If I change it to a different value, like "blue"
, or "red"
, the transition works fine.
.social-container {
position: absolute;
bottom: 0;
color: white;
border: 1px solid white;
display: flex;
width: 150px;
height: 35px;
justify-content: space-between;
align-items: center;
}
svg {
transition: fill 3s ease;
}
.instagram-logo svg * {
transition: all 2s ease;
fill: black;
}
.instagram-logo:hover svg * {
fill: url(#rg);
}
/* So I noticed the issue is the .instagram-logo:hover svg * {}. When I use a solid color like "blue" for the fill value, the transition works flawlessly. But when using the url, it doesn't work at all */
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<div class="instagram-logo">
<svg width="0" height="0">
<radialGradient id="rg" r="150%" cx="30%" cy="107%">
<stop stop-color="#fdf497" offset="0" />
<stop stop-color="#fdf497" offset="0.05" />
<stop stop-color="#fd5949" offset="0.45" />
<stop stop-color="#d6249f" offset="0.6" />
<stop stop-color="#285AEB" offset="0.9" />
</radialGradient>
</svg>
<i class="fab fa-instagram fa-2x"></i>
</div>