Applying css3 gradients with jQuery

前端 未结 6 1820
-上瘾入骨i
-上瘾入骨i 2020-12-19 01:01

Eventually, I wish to dynamically alter gradients based on different things, but how do I get jquery to apply a css3 gradient?

 //works
 $(element).css(\"bac         


        
6条回答
  •  清酒与你
    2020-12-19 01:40

    Your second approach looks OK... Maybe you need to css styles for non-webkit browsers as well... Cross-Browser CSS Gradient

    This works for me in Chrome

    $('#block').css({
        background: "-webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000))" 
    });
    

    Also have a look at: http://www.colorzilla.com/gradient-editor/

提交回复
热议问题