2016-09-01 3 views
2

ボタンをクリックしてテキストを反転しようとしています。私はボタンクリックでh1タグにアニメーション「flipInY」が必要です。
アニメーションが起こったが、デモあたりとしては、リンクの下で提供されていない:私もここにcodepen作成したボタンのクリックでAnimate.cssのフリップテキストがうまく機能しない

<html> 
<head> 
    <title></title> 
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css"> 
</head> 
<body> 
    <div> 
     My Name is <h1 id="txt">It Works!</h1> Hardik 
    </div> 
    <button type="button" id="btn">Animate</button> 
    <script src="https://code.jquery.com/jquery-2.2.4.min.js" type="text/javascript"></script> 
    <script> 
     $.fn.extend({ 
      animateCss: function (animationName) { 
       var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; 
       $(this).addClass('animated ' + animationName).one(animationEnd, function() { 
        $(this).removeClass('animated ' + animationName); 
       }); 
      } 
     }); 
     $("#btn").click(function() { 
      $('#txt').animateCss('flipInY'); 
     }); 
    </script> 
</body> 
</html> 


http://codepen.io/anon/pen/bwGdvO


https://daneden.github.io/animate.css/

が、私は以下のコードで同じアニメーションをしたいです

答えて

2

私はあなたが達成しようとしていることは簡単な修正があると信じています。

現時点では、アニメーションはページの全幅にわたるヘッダーコンテナに適用されています。

これは、display:inline-block;を使用してdiv/spanでヘッダー内のテキストを折り返し、その代わりにアニメーションを適用することで解決できます。

は、固定されたCodePenを参照してください: http://codepen.io/anon/pen/rrNOjW

+0

おおどのように愚かな私。私はアニメーションが全幅で動作していることを知らなかった。ご協力ありがとうございました –

関連する問題