Bootstrap 3.0 Modal

2020-02-23 06:45发布

问题:

I am stuck. Given Bootstrap 3.0 is about to be released, I decided to go with it for a new project. Things are going fine so far, but for the life of me, I can't figure out how to do a Modal Dialog in Bootstrap 3.0.

Does anyone have a simple example?

回答1:

You could try to build the docs: Compile Twitter bootstrap 3 docs (How to)? so also http://bassjobsen.weblogs.fm/explore-and-install-twitter-bootstrap-3/ from the docs:

  <!-- Button trigger modal -->
  <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">Launch demo modal</a>

  <!-- Modal -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">Modal title</h4>
        </div>
        <div class="modal-body">
          ...
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary">Save changes</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->


回答2:

I've found a very well example that as well let you download a zip with all the code examples about Booststrap 3 Modal.

  • Bootstrap 3 Modal explanation
  • Download Bootstrap 3 Modal demo

I hope this help you as well!



回答3:

I've been fighting against the same problem and thanks to this conversation I found my mistake. While using TwitterBootstrap3, you need the following things:

A button trigger

<a data-toggle="modal"
   href="#myModal"
   class="btn btn-primary btn-lg"
>Launch demo modal</a>

An a div with this minimun structure:

<div class="modal fade"
     id="myModal"
     tabindex="-1"
     role="dialog"
     aria-labelledby="myModalLabel"
     aria-hidden="true"
>
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- blah blah content here -->
       </div>
   </div>
</div>

It is important to know that if you don't place modal-dialog and model-content, the modal window will not be opened properly



回答4:

You can try simpleDialog. This is a simple bootstrap modal with callbacks and template injection options.