按钮hover无过渡效果最常见原因是transition未在默认状态声明且属性值不匹配:必须在非hover选择器中定义transition,并确保过渡属性在默认态和hover态均有具体可动画值。
transition 写了但没用最常见原因是 transition 只作用于「可动画的属性」,且必须在「初始状态」就声明,不能只写在 :hover 里。比如只在 :hover 中加 transition: background-color 0.3s;,浏览器根本不会触发过渡。
transition 必须写在默认(非 hover)的按钮选择器上,例如 button 或 .btn
background-color、color、transform)必须在默认态和 :hover 态都存在具体值(不能是 inherit、unset 或缺失)display: none ↔ block、height: 0 ↔ auto 都不支持过渡transition 属性写全了吗?别只写时长只写 transition: 0.3s; 是无效的——它不会自动推断要过渡哪个属性。CSS 不会“猜”你打算动背景还是边框。
transition: background-color 0.3s ease, color 0.3s ease;(明确列出属性 + 时长 + 缓动)transition: all 0.3s ease; 虽方便,但可能意外触发不需要的过渡(比如 box-shadow 或 opacity 的微小变化),还可能影响性能transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
某些颜色写法会导致 transition 中断或跳变,尤其是跨色彩模型或含透明通道时。
rgb(255, 0, 0) → hsl(0, 100%, 50%):不同色彩空间之间无法平滑插值,浏览器会降级为逐帧跳变#ff0000 → rgba(255, 0, 0, 0.8):十六进制色无 alpha,而 rgba 含透明度,浏览器无法线性混合rgba() 或 hsla() 开头,确保起始和结束值结构一致,例如:rgba(255, 0, 0, 1) → rgba(255, 0, 0, 0.9)
button {
background-color: rgba(30, 144, 255, 1);
transition: background-color 0.3s ease;
}
button:hover {
background-color: rgba(30, 144, 255, 0.9);
}
!important 或内联样式?它会绕过 transition
如果 :hover

!important,或者按钮有 style="background-color: ..." 这样的内联样式,transition 很可能被忽略——因为浏览器优先应用强制样式,跳过过渡流程。
!important,改用更精确的选择器提升权重(比如 button.primary:hover)transition 是否生效、目标属性是否被覆盖