skip to Main Content

I would like to apply animations on bootstrap3 modal box using animate.css. But it is not working for me.

Here is my code snippet

<html lang="en">
<head>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.5/custom/bootstrap.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap-theme.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.3.0/animate.min.css" rel="stylesheet" />
</head>
<body>
<a href="#myModal1" role="button" data-target="#myModal1" class="btn btn-default" data-toggle="modal">fade InLeft | OutLeft</a>
<div id="myModal1" class="modal animated fadeOutLeft" data-easein="fadeInLeft" data-easeout="fadeOutLeft" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">Modal header 1</h4>
            </div>
            <div class="modal-body">
                <p>One fine body…</p>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
                <button class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>
<a href="#myModal22" role="button" class="btn btn-default" data-toggle="modal">shake</a>
<div id="myModal22" class="modal animated rollOut" data-easein="shake" data-easeout="rollOut" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">Modal header</h4>
            </div>
            <div class="modal-body">
                <p>One fine body…</p>
            </div>
            <div class="modal-footer">
 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
            </div>
        </div>
    </div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js">  </script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script>
</body>
</html>

Please find my code snippet in below link

JSFiddle

I appreciate your help.

2

Answers


  1. I use the following javascript (jquery) extension of the bootstrap modal library to apply effects from animate.css to the modal show/hide events:

    https://gist.github.com/jduhls/92f2c7fae92da3a95c5941024847ae87

    <link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css" rel="stylesheet"/>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <script src="https://rawgit.com/jduhls/92f2c7fae92da3a95c5941024847ae87/raw/d17e48713892332af0b2afb55d34331608c46759/bootstrap-modal-animate-css.js"></script>
    
        <div id="modal" class="modal animated" data-animate-css-hide="rollOut" data-animate-css-show="rollIn">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
                                            <div class="modal-title"></div>
                                        </div>
                                        <div class="modal-body">Hello world!</div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-lg btn-default modal-submit" data-dismiss="modal" aria-hidden="true">Close</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
    <p>&nbsp;</p>
        <p><button class="btn btn-primary animated swing center-block" data-toggle="modal" data-target="#modal">Open Modal</button></p>
    
        <p>&nbsp;</p>
    
        <script src="https://gist.github.com/jduhls/92f2c7fae92da3a95c5941024847ae87.js"></script>
    Login or Signup to reply.
  2. just simply add this class animated plus the transition you want.

    for example: class="animated zoomIn"

    put this code below, something like this.

    <div class="modal animated zoomIn" tabindex="-1" role="dialog" aria-hidden="true">
    

    then let’s the animate begin!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search