Twitter Bootstrap冻结模型无法以表格或关闭模型输入数据

时间:2017-07-24 14:25:30

标签: twitter-bootstrap

我是Twitter Bootstrap的新手。我正在研究一个模态面板。当我点击按钮显示模态时,它会显示但随后会冻结。如果我点击关闭按钮或模态旁边没有任何反应,模态仍然存在,但“冻结”。表单字段也被冻结,我不能使用它们。

这是我的代码:

<div class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12">

                            <!-- Button trigger modal -->
                            <button type="button" class="btn btn-primary" data-toggle="modal"
                                data-target="#myModal">Launch demo modal</button>

                            <!-- Modal -->
                            <div class="modal fade" id="myModal">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <form>
                                        <div class="modal-header">
                                            <h5 class="modal-title">Modal title</h5>
                                            <button type="button" class="close" data-dismiss="modal"
                                                aria-label="Close">
                                                <span aria-hidden="true">&times;</span>
                                            </button>
                                        </div>
                                        <div class="modal-body">


                                                <div class="form-group label-floating">
                                                    <label class="control-label">Username</label>
                                                    <input type="text" class="form-control" />
                                                </div>

                                                <div class="form-group label-floating">
                                                    <label class="control-label">Email address</label>
                                                    <input type="email" class="form-control" />
                                                </div>

                                                <div class="form-group label-floating">
                                                    <label class="control-label">Fist Name</label>
                                                    <input type="text" class="form-control" />
                                                </div>


                                                <div class="form-group label-floating">
                                                    <label class="control-label">Last Name</label>
                                                    <input type="text" class="form-control" />
                                                </div>

                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-primary">Save
                                                changes</button>
                                            <button type="button" class="btn btn-secondary"
                                                data-dismiss="modal">Close</button>
                                            </div>
                                        </div>
                                        </form>

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

2 个答案:

答案 0 :(得分:0)

您可以使用解决方案https://jsfiddle.net/nLu3s675/

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


<div class="content">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-12">

        <!-- Button trigger modal -->
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Launch demo modal</button>

        <!-- Modal -->
        <div class="modal fade" id="myModal">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <form>
                <div class="modal-header">
                  <h5 class="modal-title">Modal title</h5>
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>
                <div class="modal-body">
                  <div class="form-group label-floating">
                    <label class="control-label">Username</label>
                    <input type="text" class="form-control" />
                  </div>

                  <div class="form-group label-floating">
                    <label class="control-label">Email address</label>
                    <input type="email" class="form-control" />
                  </div>

                  <div class="form-group label-floating">
                    <label class="control-label">Fist Name</label>
                    <input type="text" class="form-control" />
                  </div>

                  <div class="form-group label-floating">
                    <label class="control-label">Last Name</label>
                    <input type="text" class="form-control" />
                  </div>

                  <div class="modal-footer">
                    <button type="button" class="btn btn-primary">Save Changes</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

我找到了对我有用的解决方案。如果您检查上面的代码

,我已将我的模态放在另一个引导类下
<div class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12">...

这就是为什么我的模态在任何动作上被冻结的原因。当我在这些类下删除它并将其放在<body>标记下时就可以了。 这似乎是css风格的冲突。

所以看起来像:

<body>
<div class="modal fade" id="myModal">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <form>
                <div class="modal-header">
                  <h5 class="modal-title">Modal title</h5>
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>... 

希望它可以帮助有相同问题的人。