Change gradient color on hover

Hi, I'm trying to change the color of a gradient on hover, but it doesn't seem to work, and I also don't understand what the Figma file means when it shows 3 different HSL colors here:
8 Replies
MarkBoots
MarkBoots•3y ago
i think the third a white with opacity laying on top op de color gradient. you see the gradient seems lighter than the actual colors. so i think the first two colors are for the normal state and for he hover the white on top
son arg
son argOP•3y ago
son arg
son argOP•3y ago
https://jsfiddle.net/bskxp9hg/8/ I tried doing this but nothing happened Oops, I changed it from background-color to background but now the button disappears completely
Kevin Powell
Kevin Powell•3y ago
You can't transition a gradient, because it's a background-image, which isn't an animatable property. You sort of need to cheat right now, and make the gradient larger than it needs to be and animate it's position. Hard to explain in words, but I have a video on it. https://www.youtube.com/watch?v=f3mwKLXpOLk
Kevin Powell
YouTube
Fun ways to animate CSS gradients
Keep up to date on my Learn Responsive Web Design course - https://www.kevinpowell.co/learn-responsive Gradients are background-images, so we can't set up a transition on that property. It's one of the ones we simply cannot animate with CSS. Luckily, we can animate background-position, so combining that with background-size, we can do some fun...
son arg
son argOP•3y ago
Thanks! I'll check that out now 🙂
Kevin Powell
Kevin Powell•3y ago
Eventually we'll be able to do it custom properties and using @property, so we can animate each color within the gradient. Browser support sucks atm though.
MarkBoots
MarkBoots•3y ago
if you want a fade effect (instead of slide), you can use a pseudo element to put the hover state in and use opacity for the transition https://codepen.io/MarkBoots/pen/PoaqxgV
son arg
son argOP•3y ago
Thanks! That was helpful!
Want results from more Discord servers?
Add your server