模态外的自举模体内容

时间:2018-08-01 10:13:37

标签: css twitter-bootstrap twitter-bootstrap-3

我在树枝模板上有这个引导模态:

{# empty Twig template #}
<div class="modal fade" tabindex="-1" role="dialog" id="clientsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Seleccionar fechas</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="col-md-6">
                    <label for="from">Desde</label>
                    <input class="form-control datepicker" type="text" id="from">
                </div>
                <div class="col-md-6">
                    <label for="until">Hasta</label>
                    <input class="form-control datepicker" type="text" id="until">
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="clients-report-search">Buscar</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
            </div>
        </div>
    </div>
</div>

标签和输入内容位于modal-body div内,但显示在 div

标签显示在模式页脚内部,而不是正文

3 个答案:

答案 0 :(得分:0)

我对您的代码段做了一些修改。如果它解决了问题,请立即尝试

<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>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />


<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#clientsModal">
  Launch demo modal
</button>

<div class="modal fade" tabindex="-1" role="dialog" id="clientsModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Seleccionar fechas</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
      </div>
      <div class="modal-body">
        <form class="row">
          <div class="form-group col-md-6">
            <label for="from">Desde</label>
            <input class="form-control datepicker" type="text" id="from">
          </div>
          <div class="form-group col-md-6">
            <label for="until">Hasta</label>
            <input class="form-control datepicker" type="text" id="until">
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="clients-report-search">Buscar</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
      </div>
    </div>
  </div>
</div>

答案 1 :(得分:0)

尝试:-

您只能在<div class="clearfix"></div>之前使用<div class="modal-footer">

您可以将overflow:hidden;modal-content类一起使用,如下所示:-

 <div class="modal-content" style="overflow:hidden;">

答案 2 :(得分:0)

您只需要在row之后添加modal-body

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

<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#clientsModal">Open Modal</button>

<div class="modal fade" tabindex="-1" role="dialog" id="clientsModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Seleccionar fechas</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="row">
                <div class="col-md-6">
                    <label for="from">Desde</label>
                    <input class="form-control datepicker" type="text" id="from">
                </div>
                <div class="col-md-6">
                    <label for="until">Hasta</label>
                    <input class="form-control datepicker" type="text" id="until">
                </div>
              </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="clients-report-search">Buscar</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
            </div>
        </div>
    </div>
</div>