gpt4 book ai didi

jquery - jquery中的颜色转换动画

转载 作者:太空宇宙 更新时间:2023-11-03 19:41:24 25 4
gpt4 key购买 nike

如何使用 jQuery 在颜色之间设置动画,即淡出一种颜色并淡入另一种颜色。

我知道这可以通过 CSS3 关键帧来完成,但正如 w3schools 所提到的,这在 Internet Explorer 中不起作用。我想要一种适用于所有浏览器的标准方法。

在 stackoverflow 中搜索时,它提到需要一个 jQuery 颜色插件。有谁知道任何更简单的方法吗?

最佳答案

你可以试试这个:Live Demo

CSS

#content {
width: 100%;
background: #eff6f4;
transition: background 4s linear;
-webkit-transition: background 4s linear;
-moz-transition: background 4s linear;
}

JQuery

$('#content').css('background', '#C89CBD');

这将在 4 秒内更改背景颜色。

更新

如果你需要IE,那么你可以有这样的东西:

$('#content').fadeOut(500, function(){
$(this).css('background', bg).fadeIn(2000);
});

它不会那么好,但有效。 Live Demo

关于jquery - jquery中的颜色转换动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14922514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com