Use CSS3 transitions with gradient backgrounds

后端 未结 16 1585
慢半拍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 23:19

    Can't hurt to post another view since there's still not an official way to do this. Wrote a lightweight jQuery plugin with which you can define a background radial gradient and a transition speed. This basic usage will then let it fade in, optimised with requestAnimationFrame (very smooth) :

    $('#element').gradientFade({
    
        duration: 2000,
        from: '(20,20,20,1)',
        to: '(120,120,120,0)'
    });
    

    http://codepen.io/Shikkediel/pen/xbRaZz?editors=001

    Keeps original background and all properties intact. Also has highlight tracking as a setting :

    http://codepen.io/Shikkediel/pen/VYRZZY?editors=001

提交回复
热议问题