animate CSS3 gradient-positions using jQuery

前端 未结 6 494
生来不讨喜
生来不讨喜 2021-01-01 04:58

Is it possible to animate the position of a CSS3-gradient-color using jQuery?

I\'d like to animate from this

background: -moz-linear-gradient(top, #F         


        
6条回答
  •  温柔的废话
    2021-01-01 05:29

    This is a code snippet of one of my project where I use gradient transition using jquery.This may help you:

    Change Gradient
    var p1 = t = 0; var p2 = 100; function hello() { p1 = p1 + 5; p2 = 100 - p1; if(p1 <= 100 && p2 >= 0) { $('#gr_anim').css({ 'background-image':'-moz-linear-gradient('+ p1 +'% '+ p2 +'% 45deg, #000, #fff)' }); } else { clearTimeout(t); } t = setTimeout('hello()',1000);} $( function() { hello();});

提交回复
热议问题