java - jquery操作css3动画
大家讲道理
大家讲道理 2017-04-17 16:49:16
0
2
235
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
刘奇

Try animated events~~~
For example:

<!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>
<p id="page">
    <p id="single_column">
        <p id="card_options_container">
            <h1>Register with vmei.com</h1>
            <p 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>
                <p class="clear_float"></p>
                <span>Have a Sephora.com.au account?<a class="base-color" href="/users/sign_in">Sign in here</a></span>
            </p>
        </p>
    </p>
</p>
</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>
伊谢尔伦

You extract the css3 animation attribute and write it into a css class name rule, and then add the class name to the page when clicked.
As for judging the end of the animation, you can set a timer with the same duration as the animation. It will start when the animation plays and execute the callback when it ends.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!