jQuery背景色渐变动画效果

快乐打工仔 分类:实例代码

jQuery背景色渐变动画效果属于前端实例代码,有关更多实例代码大家可以查看

使用jquery实现动画效果非常的方便,不过并不是任何属性都可以使用动画来实现。

具体可以参阅jQuery的动画效果可以应用与哪些属性一章节。

如果要实现背景色渐变效果,可以使用query.color.js插件。

代码实例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>前端教程网</title>
<style type="text/css">
div{
  background-color:#bada55;
  width:100px;
  border:1px solid green;
}
</style>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script src="mytest/jQuery/jquery.color.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#go").click(function(){
    $("#block").animate({
      backgroundColor:"#abcdef"
    },1500);
  });
  $("#sat").click(function(){
    $("#block").animate({
      backgroundColor:$.Color({saturation:0})
    },1500);
  })
})
</script>
</head>
<body>
<button id="go">Simple</button>
<button id="sat">Desaturate</button>
<div id="block">前端教程网欢迎您</div>
</body>
</html>

上面的代码实现了我们的要求,能够实现背景色的动画渐变效果。

更多内容可以参阅https://github.com/jquery/jquery-color。

jQuery背景色渐变动画效果,这样的场景在实际项目中还是用的比较多的,关于jQuery背景色渐变动画效果就介绍到这了。

回复

我来回复
  • 暂无回复内容