jQuery---自定义动画效果

五迷三道 提交于 2019-11-29 06:44:20
<!DOCTYPE html>
<html lang="zh">

<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>
        h1 {
            /* display: none; */
            background-color: #f00;
            border: 5px solid #ff0;
        }
    </style>
</head>

<body>


    <p><button type="button">展开闭合</button></p>
    <h1>Hello Animation</h1>
    <h1>Hello Animation</h1>
    <h1>Hello Animation</h1>

    <script src="./jquery.js"></script>
    <script>

        $('button[type="button"]').click(function () {
            
            // 使用 animate() 方法自定义动画效果
            
            $('h1').animate({
                borderRadius: '50%',
                width: '200px'
            }, 10 * 1000, 'linear', function() {
                console.log('动画执行完毕')
            })

            // 注意:该方法不能变换以下 CSS 属性:
            // color
            // backgroundColor
            // borderTopColor
            // borderRightColor
            // borderBottomColor
            // borderLeftColor
            // borderColor
            // outlineColor
        })

    </script>
</body>

</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!