【问题标题】:jquery .animate opacity and background color at same time on the same elementjquery .animate 不透明度和背景颜色同时在同一个元素上
【发布时间】:2012-09-13 16:24:13
【问题描述】:

我正在尝试同时为元素的不透明度和背景颜色设置动画。我正在使用下面的代码,但目前只有不透明度动画。

$("div.offer").mouseover(function() {
var myClass = $(this).attr("class");

$(this).stop().animate({width:'259px'}, {queue:false, duration:600, easing:'easeOutQuint'});

if (myClass == "offer windows") {
    $(".offer.windows .offerBackground").stop().animate({opacity:'1'}, {queue:false, duration:600, easing:'easeOutQuint'});
    $(".offer.windows .offerBackground").stop().animate({backgroundColor:'#B0C1C8'}, {queue:false, duration:600, easing:'linear'});
}
});

是否可以同时为两者制作动画?

【问题讨论】:

  • 您需要 jQueryUI 来为颜色设置动画:?.. 或者您可以使用 CSS 轻松完成这一切。

标签: jquery jquery-animate opacity background-color


【解决方案1】:

对于动画颜色,您需要使用jQuery UI。 jQuery 核心本身不会为与颜色相关的属性设置动画。

【讨论】:

  • 感谢您的回答。我在原来的描述中犯了一个错误。目前 backgroundColor 动画,但 opacity 没有。但是,如果我将“动画不透明度”命令放在“动画背景颜色”命令下方,那么不透明度就会动画。有没有办法让它们都动画化?
猜你喜欢
  • 1970-01-01
  • 2011-07-13
  • 1970-01-01
  • 2013-02-05
  • 1970-01-01
  • 2014-01-24
  • 2011-08-29
  • 2021-10-26
  • 2017-03-15
相关资源
最近更新 更多