jquery操作css3动画-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

jquery操作css3动画

蛮大人123 2016-03-10 14:50:28 1518

我想在点击card_options_btn判断动画走到0点进行js操作要怎么改
比如为0点弹出个alert

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="../jquery.1.9.1.min.js" ></script>
        <style type="text/css">
            html{background-color: #fff;font-family: Arial, sans-serif;font-size: 12px;color: #000;}
            body{text-rendering: optimizeLegibility;-webkit-font-smoothing: antialiased;-webkit-text-size-adjust: 100%;width: 100%;margin: 0;padding: 0}
            a {color: #000;text-decoration: none;}
            #page{width: 1125px;margin: 0px auto;display: block;margin-top: 10px;height: 274px;}
            #single_column{background-color: #fff;padding: 30px;padding-bottom: 50px;}
            #card_options_container h1{font-family:"Avalon-Medium", Roboto, Arial, sans-serif;font-weight:normal;color:#000;font-size:2em;text-transform:uppercase;font-weight:bold;margin-bottom:20px;text-align: center;}
            .register_signin_switcher {margin: 20px 0;text-align: center;}
            #card_options_container .card_options_btn {display: inline-block;padding: 20px;min-width: 280px;font-size: 18px;text-transform: uppercase;margin: 10px 10px 20px;border: 2px solid #000;}
            .card_options_btn:hover{color:red;border: 2px solid red !important;}
            .clear_float {overflow: hidden;width: 100%;clear: both;}
            .base-color {text-decoration: underline;color: #d50032;}
            
            @keyframes autoh{
                form {height:auto;}
                to   {height: 0;}
            }
            @-webkit-keyframes autoh{
                form {height:auto;}
                to   {height: 0;}
            }
        </style>
    </head>
    <body>
        <div id="page">
            <div id="single_column">
                <div id="card_options_container">
                    <h1>Register with vmei.com</h1>
                    <div class="register_signin_switcher center">
                        <a class="card_options_btn show_with" href="#">I have a Sephora  Card</a>
                        <a class="card_options_btn show_without" href="#">I don't have a Sephora Card</a>
                        <div class="clear_float"></div>
                        <span>Have a Sephora.com.au account?<a class="base-color" href="/users/sign_in">Sign in here</a></span>
                     </div>
                </div>
            </div>
        </div>
    </body>
    <script type="text/javascript">
        $(function(){
            $(".register_signin_switcher").on("click",".card_options_btn",function(){
                $("#page").css({"-webkit-animation":"autoh 2s","animation":"autoh 2s","overflow":"hidden"});
            })
        })
    </script>
</html>
前端开发 JavaScript
分享到
取消 提交回答
全部回答(1)
  • 蛮大人123
    2019-07-17 18:57:41

    试试动画事件
    例如:

    <!DOCTYPE html>
    <html>
    <head>
        <title>AnimationTest</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="../script/jquery-2.1.3.min.js"></script>
        <style type="text/css">
            html{background-color: #fff;font-family: Arial, sans-serif;font-size: 12px;color: #000;}
            body{text-rendering: optimizeLegibility;-webkit-font-smoothing: antialiased;-webkit-text-size-adjust: 100%;width: 100%;margin: 0;padding: 0}
            a {color: #000;text-decoration: none;}
            #page{width: 1125px;margin: 0px auto;display: block;margin-top: 10px;height: 274px;}
            #single_column{background-color: #fff;padding: 30px;padding-bottom: 50px;}
            #card_options_container h1{font-family:"Avalon-Medium", Roboto, Arial, sans-serif;font-weight:normal;color:#000;font-size:2em;text-transform:uppercase;font-weight:bold;margin-bottom:20px;text-align: center;}
            .register_signin_switcher {margin: 20px 0;text-align: center;}
            #card_options_container .card_options_btn {display: inline-block;padding: 20px;min-width: 280px;font-size: 18px;text-transform: uppercase;margin: 10px 10px 20px;border: 2px solid #000;}
            .card_options_btn:hover{color:red;border: 2px solid red !important;}
            .clear_float {overflow: hidden;width: 100%;clear: both;}
            .base-color {text-decoration: underline;color: #d50032;}
            @keyframes autoh{
                form {height:auto;}
                to   {height: 0;}
            }
            @-webkit-keyframes autoh{
                form {height:auto;}
                to   {height: 0;}
            }
            .pageAnima {
            -webkit-animation:autoh 2s;
            animation:autoh 2s;
            overflow:hidden;
            }
        </style>
    </head>
    <body>
    <div id="page">
        <div id="single_column">
            <div id="card_options_container">
                <h1>Register with vmei.com</h1>
                <div class="register_signin_switcher center">
                    <a class="card_options_btn show_with" href="#">I have a Sephora  Card</a>
                    <a class="card_options_btn show_without" href="#">I don't have a Sephora Card</a>
                    <div class="clear_float"></div>
                    <span>Have a Sephora.com.au account?<a class="base-color" href="/users/sign_in">Sign in here</a></span>
                </div>
            </div>
        </div>
    </div>
    </body>
    <script type="text/javascript">
        $(function(){
           $(".register_signin_switcher").on("click",".card_options_btn",function(){
    
                $("#page").removeClass('pageAnima').addClass('pageAnima');
                //$("#page").css({"-webkit-animation":"autoh 2s","animation":"autoh 2s","overflow":"hidden"});
            });
            $('#page').on("animationend",function(){
                console.log('animationend');
                $("#page").removeClass('pageAnima')
            });
        })
    </script>
    </html>
    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程