Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Modal do not fade

I have a very simple HTML that should open a fading modal, but it only shows and hide without fading in or out.

Here is the code:

<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="css/bootstrap.css" />
        <script type="text/javascript" src="jquery.min.js"></script>
        <script type="text/javascript" src="js/bootstrap-modal.js"></script>
    </head>
    <body>
        <div id="myModal" class="modal hide fade">
            <div class="modal-header"><h4>I'm a header</h4></div>
            <div class="modal-body"><p>Hello from the body</p></div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                <button class="btn btn-primary">Save changes</button>
            </div>
        </div>

        <a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch Modal</a>
    </body>
</html>

This code was taken from Twitter Bootstrap docs.

In jsFiddle this simple code works just great! But if I save the above code like .html inside a folder with all required files (.css and .js), modal open in a simple way, without fading!

What am I doing wrong?

Thanks in advance.

like image 914
Marcio Martins Avatar asked Feb 19 '23 23:02

Marcio Martins


2 Answers

That is because the modal effects are CSS3 effects and you're not including the plugin that handles that, so just load the bootstrap-transition.js plugin before the modal plugin and it should work.

like image 74
Andres Ilich Avatar answered Feb 27 '23 13:02

Andres Ilich


When using only bootstrap-modal.js, I experience the same as you. But it works when i use the compiled bootstrap.js

like image 27
Werner Kvalem Vesterås Avatar answered Feb 27 '23 13:02

Werner Kvalem Vesterås