CodexBloom - Programming Q&A Platform

CSS Animation Not Playing on Hover in WebKit Browsers Even After Specifying Keyframes

👀 Views: 33 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
css animation webkit cross-browser CSS

Can someone help me understand I'm trying to implement I just started working with I've searched everywhere and can't find a clear answer... I'm working with an scenario where a CSS animation fails to trigger on hover in WebKit-based browsers like Safari and Chrome 117, even though it works perfectly in Firefox. I'm trying to create a simple hover effect that scales a button using keyframes. Here's the relevant CSS code: ```css @keyframes scaleUp { 0% { transform: scale(1); } 100% { transform: scale(1.1); } } .button { padding: 10px 20px; background-color: #007bff; color: white; border: none; cursor: pointer; animation: scaleUp 0.3s ease; } .button:hover { animation: scaleUp 0.3s ease forwards; } ``` I've ensured that my browser is up-to-date and cleared the cache, yet the animation does not play when I hover over the button. I've tried adding the `!important` declaration to the animation in the hover state, but that hasn't resolved the scenario either. In my development environment, I'm using Chrome 117 and Safari 16.1, along with a standard HTML structure: ```html <button class="button">Hover me!</button> ``` I also checked the console for any warnings or errors, but there are none related to CSS. Is there something specific to WebKit rendering that I might have overlooked? Or is there a better way to implement this hover animation that ensures cross-browser compatibility? I'm working on a CLI tool that needs to handle this. What's the best practice here? This is for a service running on Ubuntu 20.04. Any advice would be much appreciated. Am I approaching this the right way? For reference, this is a production service. Any examples would be super helpful.