光阴似箭催人老,日月如移越少年。
试试动画事件~~~例如:
<!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>
你把css3 animation属性抽出写成一个css类名规则,然后点击时给页面加上类名。至于判断动画结束,你就设个和动画一样时长的定时器,动画播放时启动,结束时就执行回调。
试试动画事件~~~
例如:
你把css3 animation属性抽出写成一个css类名规则,然后点击时给页面加上类名。
至于判断动画结束,你就设个和动画一样时长的定时器,动画播放时启动,结束时就执行回调。