如何在bootstrap3模式框上应用animation .css



我想使用animation .css在bootstrap3模式框上应用动画。但这对我不起作用。

这是我的代码片段
<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>

请在下面的链接找到我的代码片段

JSFiddle

感谢你的帮助。

我使用以下javascript (jquery)扩展的bootstrap模态库应用效果从animation .css到模态显示/隐藏事件:

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>

只需添加这个类动画加上你想要的过渡。

例如:class="animated zoomIn"

把这段代码放在下面,就像这样

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

那么让我们开始动画吧!

最新更新