我没能在bootstrap 3中弹出模态

时间:2015-07-10 05:13:10

标签: bootstrap-modal

这是我写的代码。我已经检查了与此相关的查询,在其他平台和论坛上,类似的编码工作但不适合我

<div style="text-align: center; width: 100%">
    <button style="position: absolute; top: 50%" type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">SUBSCRIBE</button>
</div>
<!-- Modal -->
<div class="modal" id="myModal" role="dialog" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <!-- modal header -->
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <!-- modal body -->
            <div class="modal-body">
                <form role="form">
                    <div class="form-group">
                    <input type="email" class="form-control" placeholder="Email">

                    </div>
                </form>
            </div>

            <!-- modal footer -->
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

你是否包含了bootstrap.js? (最好在身体末端)

答案 1 :(得分:0)

这是有效的。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />


<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<div style="text-align: center; width: 100%">
  <button style="position: absolute; top: 50%" type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">SUBSCRIBE</button>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <!-- modal header -->
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <!-- modal body -->
      <div class="modal-body">
        <form role="form">
          <div class="form-group">
            <input type="email" class="form-control" placeholder="Email" />
          </div>
        </form>
      </div>
      <!-- modal footer -->
      <div class="modal-footer"></div>
    </div>
  </div>
</div>