jquery中的动画操作

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box{
            width: 20px;
            height: 200px;
            background:red;
        }
        
        .box1{

            width: 20px;
            height: 200px;
            background: green;
        }
    </style>
    <script src="./jquery-1.12.4.min.js"></script>
    <script src="./jquery.color.js"></script>
    <script>
        $(function(){

            var $div = $('.box');
            //1.动画的属性,jquery只对尺寸,也就是px有效果(第一个参数)
            //2.动画时长的代表了速度 时间是用毫秒来表示(第二个参数)
            //3.动画的样式:linear和swing(第三个参数)
            //4.complete 动画完成(第四个参数)
            $div.animate({"width":"1000px","background-color":"yellow"},3000,"linear")
            $('.box1').animate({"height":"300px","width":"1000px"},3000)

            //如果相对动画的颜色作变化,还要导入一个包,必须要在jquery下导入

        })
    
    </script>
</head>
<body>
    <div class="box"></div>
    <div class="box1"></div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/owc1874/article/details/80747288