Use CSS3 transitions with gradient backgrounds

后端 未结 16 1578
慢半拍i
慢半拍i 2020-11-21 22:18

I\'m trying to transition on hover with css over a thumbnail so that on hover, the background gradient fades in. The transition isn\'t working, but if I simply change it to

16条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 22:58

    Gradients don't support transitions yet (although the current spec says they should support like gradient to like gradient transitions via interpolation.).

    If you want a fade-in effect with a background gradient, you have to set an opacity on a container element and 'transition` the opacity.

    (There have been some browser releases that supported transitions on gradients (e.g IE10. I tested gradient transitions in 2016 in IE and they seemed to work at the time, but my test code no longer works.)

    Update: October 2018 Gradient transitions with un-prefixed new syntax [e.g. radial-gradient(...)]now confirmed to work (again?) on Microsoft Edge 17.17134. I don't know when this was added. Still not working on latest Firefox & Chrome / Windows 10.

提交回复
热议问题