jQuery animate backgroundColor

前端 未结 17 2461
醉梦人生
醉梦人生 2020-11-21 07:11

I am trying to animate a change in backgroundColor using jQuery on mouseover.

I have checked some example and I seem to have it right, it works with other properties

17条回答
  •  生来不讨喜
    2020-11-21 07:50

    Do it with CSS3-Transitions. Support is great (all modern browsers, even IE). With Compass and SASS this is quickly done:

    #foo {background:red; @include transition(background 1s)}
    #foo:hover {background:yellow}
    

    Pure CSS:

    #foo {
    background:red;
    -webkit-transition:background 1s;
    -moz-transition:background 1s;
    -o-transition:background 1s;
    transition:background 1s
    }
    #foo:hover {background:yellow}
    

    I've wrote an german article about this topic: http://www.solife.cc/blog/animation-farben-css3-transition.html

提交回复
热议问题